github-url-detection 5.13.0 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,403 +1,558 @@
1
- var reservedNames = [ "400", "401", "402", "403", "404", "405", "406", "407", "408", "409", "410", "411", "412", "413", "414", "415", "416", "417", "418", "419", "420", "421", "422", "423", "424", "425", "426", "427", "428", "429", "430", "431", "500", "501", "502", "503", "504", "505", "506", "507", "508", "509", "510", "511", "about", "access", "account", "admin", "advisories", "anonymous", "any", "api", "apps", "attributes", "auth", "billing", "blob", "blog", "bounty", "branches", "business", "businesses", "c", "cache", "case-studies", "categories", "central", "certification", "changelog", "cla", "cloud", "codereview", "collection", "collections", "comments", "commit", "commits", "community", "companies", "compare", "contact", "contributing", "cookbook", "coupons", "customer-stories", "customer", "customers", "dashboard", "dashboards", "design", "develop", "developer", "diff", "discover", "discussions", "docs", "downloads", "downtime", "editor", "editors", "edu", "enterprise", "events", "explore", "featured", "features", "files", "fixtures", "forked", "garage", "ghost", "gist", "gists", "graphs", "guide", "guides", "help", "help-wanted", "home", "hooks", "hosting", "hovercards", "identity", "images", "inbox", "individual", "info", "integration", "interfaces", "introduction", "invalid-email-address", "investors", "issues", "jobs", "join", "journal", "journals", "lab", "labs", "languages", "launch", "layouts", "learn", "legal", "library", "linux", "listings", "lists", "login", "logos", "logout", "mac", "maintenance", "malware", "man", "marketplace", "mention", "mentioned", "mentioning", "mentions", "migrating", "milestones", "mine", "mirrors", "mobile", "navigation", "network", "new", "news", "none", "nonprofit", "nonprofits", "notices", "notifications", "oauth", "offer", "open-source", "organisations", "organizations", "orgs", "pages", "partners", "payments", "personal", "plans", "plugins", "popular", "popularity", "posts", "press", "pricing", "professional", "projects", "pulls", "raw", "readme", "recommendations", "redeem", "releases", "render", "reply", "repositories", "resources", "restore", "revert", "save-net-neutrality", "saved", "scraping", "search", "security", "services", "sessions", "settings", "shareholders", "shop", "showcases", "signin", "signup", "site", "spam", "sponsors", "ssh", "staff", "starred", "stars", "static", "status", "statuses", "storage", "store", "stories", "styleguide", "subscriptions", "suggest", "suggestion", "suggestions", "support", "suspended", "talks", "teach", "teacher", "teachers", "teaching", "team", "teams", "ten", "terms", "timeline", "topic", "topics", "tos", "tour", "train", "training", "translations", "tree", "trending", "updates", "username", "users", "visualization", "w", "watching", "wiki", "windows", "works-with", "www0", "www1", "www2", "www3", "www4", "www5", "www6", "www7", "www8", "www9" ];
2
-
3
- const $ = selector => document.querySelector(selector);
4
-
5
- const exists = selector => Boolean($(selector));
6
-
7
- const is404 = () => document.title.startsWith("Page not found · GitHub");
8
-
9
- const is500 = () => "Server Error · GitHub" === document.title || "Unicorn! · GitHub" === document.title || "504 Gateway Time-out" === document.title;
10
-
11
- const isPasswordConfirmation = () => "Confirm password" === document.title || "Confirm access" === document.title;
12
-
13
- const isBlame = (url = location) => {
14
- var _a;
15
- return Boolean(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path.startsWith("blame/"));
16
- };
17
-
1
+ const reservedNames = [
2
+ "400",
3
+ "401",
4
+ "402",
5
+ "403",
6
+ "404",
7
+ "405",
8
+ "406",
9
+ "407",
10
+ "408",
11
+ "409",
12
+ "410",
13
+ "411",
14
+ "412",
15
+ "413",
16
+ "414",
17
+ "415",
18
+ "416",
19
+ "417",
20
+ "418",
21
+ "419",
22
+ "420",
23
+ "421",
24
+ "422",
25
+ "423",
26
+ "424",
27
+ "425",
28
+ "426",
29
+ "427",
30
+ "428",
31
+ "429",
32
+ "430",
33
+ "431",
34
+ "500",
35
+ "501",
36
+ "502",
37
+ "503",
38
+ "504",
39
+ "505",
40
+ "506",
41
+ "507",
42
+ "508",
43
+ "509",
44
+ "510",
45
+ "511",
46
+ "about",
47
+ "access",
48
+ "account",
49
+ "admin",
50
+ "advisories",
51
+ "anonymous",
52
+ "any",
53
+ "api",
54
+ "apps",
55
+ "attributes",
56
+ "auth",
57
+ "billing",
58
+ "blob",
59
+ "blog",
60
+ "bounty",
61
+ "branches",
62
+ "business",
63
+ "businesses",
64
+ "c",
65
+ "cache",
66
+ "case-studies",
67
+ "categories",
68
+ "central",
69
+ "certification",
70
+ "changelog",
71
+ "cla",
72
+ "cloud",
73
+ "codereview",
74
+ "collection",
75
+ "collections",
76
+ "comments",
77
+ "commit",
78
+ "commits",
79
+ "community",
80
+ "companies",
81
+ "compare",
82
+ "contact",
83
+ "contributing",
84
+ "cookbook",
85
+ "coupons",
86
+ "customer-stories",
87
+ "customer",
88
+ "customers",
89
+ "dashboard",
90
+ "dashboards",
91
+ "design",
92
+ "develop",
93
+ "developer",
94
+ "diff",
95
+ "discover",
96
+ "discussions",
97
+ "docs",
98
+ "downloads",
99
+ "downtime",
100
+ "editor",
101
+ "editors",
102
+ "edu",
103
+ "enterprise",
104
+ "events",
105
+ "explore",
106
+ "featured",
107
+ "features",
108
+ "files",
109
+ "fixtures",
110
+ "forked",
111
+ "garage",
112
+ "ghost",
113
+ "gist",
114
+ "gists",
115
+ "graphs",
116
+ "guide",
117
+ "guides",
118
+ "help",
119
+ "help-wanted",
120
+ "home",
121
+ "hooks",
122
+ "hosting",
123
+ "hovercards",
124
+ "identity",
125
+ "images",
126
+ "inbox",
127
+ "individual",
128
+ "info",
129
+ "integration",
130
+ "interfaces",
131
+ "introduction",
132
+ "invalid-email-address",
133
+ "investors",
134
+ "issues",
135
+ "jobs",
136
+ "join",
137
+ "journal",
138
+ "journals",
139
+ "lab",
140
+ "labs",
141
+ "languages",
142
+ "launch",
143
+ "layouts",
144
+ "learn",
145
+ "legal",
146
+ "library",
147
+ "linux",
148
+ "listings",
149
+ "lists",
150
+ "login",
151
+ "logos",
152
+ "logout",
153
+ "mac",
154
+ "maintenance",
155
+ "malware",
156
+ "man",
157
+ "marketplace",
158
+ "mention",
159
+ "mentioned",
160
+ "mentioning",
161
+ "mentions",
162
+ "migrating",
163
+ "milestones",
164
+ "mine",
165
+ "mirrors",
166
+ "mobile",
167
+ "navigation",
168
+ "network",
169
+ "new",
170
+ "news",
171
+ "none",
172
+ "nonprofit",
173
+ "nonprofits",
174
+ "notices",
175
+ "notifications",
176
+ "oauth",
177
+ "offer",
178
+ "open-source",
179
+ "organisations",
180
+ "organizations",
181
+ "orgs",
182
+ "pages",
183
+ "partners",
184
+ "payments",
185
+ "personal",
186
+ "plans",
187
+ "plugins",
188
+ "popular",
189
+ "popularity",
190
+ "posts",
191
+ "press",
192
+ "pricing",
193
+ "professional",
194
+ "projects",
195
+ "pulls",
196
+ "raw",
197
+ "readme",
198
+ "recommendations",
199
+ "redeem",
200
+ "releases",
201
+ "render",
202
+ "reply",
203
+ "repositories",
204
+ "resources",
205
+ "restore",
206
+ "revert",
207
+ "save-net-neutrality",
208
+ "saved",
209
+ "scraping",
210
+ "search",
211
+ "security",
212
+ "services",
213
+ "sessions",
214
+ "settings",
215
+ "shareholders",
216
+ "shop",
217
+ "showcases",
218
+ "signin",
219
+ "signup",
220
+ "site",
221
+ "spam",
222
+ "sponsors",
223
+ "ssh",
224
+ "staff",
225
+ "starred",
226
+ "stars",
227
+ "static",
228
+ "status",
229
+ "statuses",
230
+ "storage",
231
+ "store",
232
+ "stories",
233
+ "styleguide",
234
+ "subscriptions",
235
+ "suggest",
236
+ "suggestion",
237
+ "suggestions",
238
+ "support",
239
+ "suspended",
240
+ "talks",
241
+ "teach",
242
+ "teacher",
243
+ "teachers",
244
+ "teaching",
245
+ "team",
246
+ "teams",
247
+ "ten",
248
+ "terms",
249
+ "timeline",
250
+ "topic",
251
+ "topics",
252
+ "tos",
253
+ "tour",
254
+ "train",
255
+ "training",
256
+ "translations",
257
+ "tree",
258
+ "trending",
259
+ "updates",
260
+ "username",
261
+ "users",
262
+ "visualization",
263
+ "w",
264
+ "watching",
265
+ "wiki",
266
+ "windows",
267
+ "works-with",
268
+ "www0",
269
+ "www1",
270
+ "www2",
271
+ "www3",
272
+ "www4",
273
+ "www5",
274
+ "www6",
275
+ "www7",
276
+ "www8",
277
+ "www9"
278
+ ];
279
+ const $ = (selector) => document.querySelector(selector);
280
+ const exists = (selector) => Boolean($(selector));
281
+ const is404 = () => document.title.startsWith("Page not found \xB7 GitHub");
282
+ const is500 = () => document.title === "Server Error \xB7 GitHub" || document.title === "Unicorn! \xB7 GitHub" || document.title === "504 Gateway Time-out";
283
+ const isPasswordConfirmation = () => document.title === "Confirm password" || document.title === "Confirm access";
284
+ const isBlame = (url = location) => Boolean(getRepo(url)?.path.startsWith("blame/"));
18
285
  const isCommit = (url = location) => isSingleCommit(url) || isPRCommit(url);
19
-
20
286
  const isCommitList = (url = location) => isRepoCommitList(url) || isPRCommitList(url);
21
-
22
- const isRepoCommitList = (url = location) => {
23
- var _a;
24
- return Boolean(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path.startsWith("commits"));
25
- };
26
-
27
- const isCompare = (url = location) => {
28
- var _a;
29
- return Boolean(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path.startsWith("compare"));
30
- };
31
-
287
+ const isRepoCommitList = (url = location) => Boolean(getRepo(url)?.path.startsWith("commits"));
288
+ const isCompare = (url = location) => Boolean(getRepo(url)?.path.startsWith("compare"));
32
289
  const isCompareWikiPage = (url = location) => isRepoWiki(url) && getCleanPathname(url).split("/").slice(3, 5).includes("_compare");
33
-
34
290
  const isDashboard = (url = location) => !isGist(url) && /^$|^(orgs\/[^/]+\/)?dashboard(\/|$)/.test(getCleanPathname(url));
35
-
36
- const isEnterprise = (url = location) => "github.com" !== url.hostname && "gist.github.com" !== url.hostname;
37
-
38
- const isGist = (url = location) => url.hostname.startsWith("gist.") || "gist" === url.pathname.split("/", 2)[1];
39
-
40
- const isGlobalConversationList = (url = location) => [ "issues", "pulls" ].includes(url.pathname.split("/", 2)[1]);
41
-
42
- const isGlobalSearchResults = (url = location) => "/search" === url.pathname && null !== new URLSearchParams(url.search).get("q");
43
-
44
- const isIssue = (url = location) => {
45
- var _a;
46
- return /^issues\/\d+/.test(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path) && "GitHub · Where software is built" !== document.title;
47
- };
48
-
49
- const isConversationList = (url = location) => isGlobalConversationList(url) || isRepoConversationList(url) || isMilestone(url);
50
-
291
+ const isEnterprise = (url = location) => url.hostname !== "github.com" && url.hostname !== "gist.github.com";
292
+ const isGist = (url = location) => typeof getCleanGistPathname(url) === "string";
293
+ const isGlobalIssueOrPRList = (url = location) => ["issues", "pulls"].includes(url.pathname.split("/", 2)[1]);
294
+ const isGlobalSearchResults = (url = location) => url.pathname === "/search" && new URLSearchParams(url.search).get("q") !== null;
295
+ const isIssue = (url = location) => /^issues\/\d+/.test(getRepo(url)?.path) && document.title !== "GitHub \xB7 Where software is built";
296
+ const isIssueOrPRList = (url = location) => isGlobalIssueOrPRList(url) || isRepoIssueOrPRList(url) || isMilestone(url);
51
297
  const isConversation = (url = location) => isIssue(url) || isPRConversation(url);
52
-
53
- const isLabelList = (url = location) => {
54
- var _a;
55
- return "labels" === (null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
56
- };
57
-
58
- const isMilestone = (url = location) => {
59
- var _a;
60
- return /^milestone\/\d+/.test(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
61
- };
62
-
63
- const isMilestoneList = (url = location) => {
64
- var _a;
65
- return "milestones" === (null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
66
- };
67
-
68
- const isNewFile = (url = location) => {
69
- var _a;
70
- return Boolean(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path.startsWith("new"));
71
- };
72
-
73
- const isNewIssue = (url = location) => {
74
- var _a;
75
- return "issues/new" === (null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
76
- };
77
-
78
- const isNewRelease = (url = location) => {
79
- var _a;
80
- return "releases/new" === (null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
81
- };
82
-
298
+ const isLabelList = (url = location) => getRepo(url)?.path === "labels";
299
+ const isMilestone = (url = location) => /^milestone\/\d+/.test(getRepo(url)?.path);
300
+ const isMilestoneList = (url = location) => getRepo(url)?.path === "milestones";
301
+ const isNewFile = (url = location) => Boolean(getRepo(url)?.path.startsWith("new"));
302
+ const isNewIssue = (url = location) => getRepo(url)?.path === "issues/new";
303
+ const isNewRelease = (url = location) => getRepo(url)?.path === "releases/new";
83
304
  const isNewWikiPage = (url = location) => isRepoWiki(url) && getCleanPathname(url).endsWith("/_new");
84
-
85
- const isNotifications = (url = location) => "notifications" === getCleanPathname(url);
86
-
305
+ const isNotifications = (url = location) => getCleanPathname(url) === "notifications";
87
306
  const isOrganizationProfile = () => exists('meta[name="hovercard-subject-tag"][content^="organization"]');
88
-
89
- const isOrganizationRepo = () => {
90
- var _a;
91
- return Boolean(null === (_a = document.querySelector("[data-owner-scoped-search-url]")) || void 0 === _a ? void 0 : _a.dataset.ownerScopedSearchUrl.startsWith("/org"));
92
- };
93
-
94
- const isOrganizationDiscussion = (url = location) => /^orgs\/[^/]+\/teams\/[^/]+($|\/discussions)/.test(getCleanPathname(url));
95
-
307
+ const isOrganizationRepo = () => Boolean(document.querySelector("[data-owner-scoped-search-url]")?.dataset["ownerScopedSearchUrl"].startsWith("/org"));
308
+ const isTeamDiscussion = (url = location) => /^orgs\/[^/]+\/teams\/[^/]+($|\/discussions)/.test(getCleanPathname(url));
96
309
  const isOwnUserProfile = () => getCleanPathname() === getUsername();
97
-
98
310
  const isOwnOrganizationProfile = () => isOrganizationProfile() && !exists('[href*="contact/report-abuse?report="]');
99
-
100
- const isProject = (url = location) => {
101
- var _a;
102
- return /^projects\/\d+/.test(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
103
- };
104
-
105
- const isProjects = (url = location) => {
106
- var _a;
107
- return "projects" === (null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
108
- };
109
-
110
- const isDiscussion = (url = location) => {
111
- var _a;
112
- return /^discussions\/\d+/.test(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
113
- };
114
-
115
- const isDiscussionList = (url = location) => {
116
- var _a;
117
- return "discussions" === (null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
118
- };
119
-
120
- const isPR = (url = location) => {
121
- var _a;
122
- return /^pull\/\d+/.test(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path) && !isPRConflicts(url);
123
- };
124
-
125
- const isPRConflicts = (url = location) => {
126
- var _a;
127
- return /^pull\/\d+\/conflicts/.test(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
128
- };
129
-
130
- const isPRList = (url = location) => {
131
- var _a;
132
- return "/pulls" === url.pathname || "pulls" === (null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
133
- };
134
-
135
- const isPRCommit = (url = location) => {
136
- var _a;
137
- return /^pull\/\d+\/commits\/[\da-f]{5,40}$/.test(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
138
- };
139
-
140
- const isPRCommit404 = () => isPRCommit() && document.title.startsWith("Commit range not found · Pull Request");
141
-
142
- const isPRFile404 = () => isPRFiles() && document.title.startsWith("Commit range not found · Pull Request");
143
-
144
- const isPRConversation = (url = location) => {
145
- var _a;
146
- return /^pull\/\d+$/.test(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
147
- };
148
-
149
- const isPRCommitList = (url = location) => {
150
- var _a;
151
- return /^pull\/\d+\/commits$/.test(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
152
- };
153
-
154
- const isPRFiles = (url = location) => {
155
- var _a;
156
- return /^pull\/\d+\/files/.test(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
157
- };
158
-
311
+ const isProject = (url = location) => /^projects\/\d+/.test(getRepo(url)?.path);
312
+ const isProjects = (url = location) => getRepo(url)?.path === "projects";
313
+ const isDiscussion = (url = location) => /^discussions\/\d+/.test(getRepo(url)?.path);
314
+ const isDiscussionList = (url = location) => getRepo(url)?.path === "discussions";
315
+ const isPR = (url = location) => /^pull\/\d+/.test(getRepo(url)?.path) && !isPRConflicts(url);
316
+ const isPRConflicts = (url = location) => /^pull\/\d+\/conflicts/.test(getRepo(url)?.path);
317
+ const isPRList = (url = location) => url.pathname === "/pulls" || getRepo(url)?.path === "pulls";
318
+ const isPRCommit = (url = location) => /^pull\/\d+\/commits\/[\da-f]{5,40}$/.test(getRepo(url)?.path);
319
+ const isPRCommit404 = () => isPRCommit() && document.title.startsWith("Commit range not found \xB7 Pull Request");
320
+ const isPRFile404 = () => isPRFiles() && document.title.startsWith("Commit range not found \xB7 Pull Request");
321
+ const isPRConversation = (url = location) => /^pull\/\d+$/.test(getRepo(url)?.path);
322
+ const isPRCommitList = (url = location) => /^pull\/\d+\/commits$/.test(getRepo(url)?.path);
323
+ const isPRFiles = (url = location) => /^pull\/\d+\/files/.test(getRepo(url)?.path);
159
324
  const isQuickPR = (url = location) => isCompare(url) && /[?&]quick_pull=1(&|$)/.test(url.search);
160
-
161
- const isDraftPR = () => exists('#partial-discussion-header [title="Status: Draft"]');
162
-
163
- const isOpenPR = () => exists('#partial-discussion-header [title="Status: Open"], #partial-discussion-header [title="Status: Draft"]');
164
-
165
- const isMergedPR = () => exists('#partial-discussion-header [title="Status: Merged"]');
166
-
167
- const isClosedConversation = () => exists('#partial-discussion-header :is([title="Status: Closed"], [title="Status: Merged"], [title="Status: Closed as not planned"])');
168
-
169
- const isClosedPR = isClosedConversation;
170
-
171
- const isReleases = (url = location) => {
172
- var _a;
173
- return "releases" === (null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
174
- };
175
-
176
- const isTags = (url = location) => {
177
- var _a;
178
- return "tags" === (null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
179
- };
180
-
181
- const isSingleTag = (url = location) => {
182
- var _a;
183
- return /^(releases\/tag)/.test(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
184
- };
185
-
325
+ const isDraftPR = () => exists("#partial-discussion-header .octicon-git-pull-request-draft");
326
+ const isOpenPR = () => exists("#partial-discussion-header :is(.octicon-git-pull-request, .octicon-git-pull-request-draft)");
327
+ const isMergedPR = () => exists("#partial-discussion-header .octicon-git-merge");
328
+ const isClosedPR = () => exists("#partial-discussion-header :is(.octicon-git-pull-request-closed, .octicon-git-merge)");
329
+ const isClosedIssue = () => exists("#partial-discussion-header :is(.octicon-issue-closed, .octicon-skip)");
330
+ const isReleases = (url = location) => getRepo(url)?.path === "releases";
331
+ const isTags = (url = location) => getRepo(url)?.path === "tags";
332
+ const isSingleTag = (url = location) => /^(releases\/tag)/.test(getRepo(url)?.path);
186
333
  const isReleasesOrTags = (url = location) => isReleases(url) || isTags(url) || isSingleTag(url);
187
-
188
- const isDeletingFile = (url = location) => {
189
- var _a;
190
- return Boolean(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path.startsWith("delete"));
191
- };
192
-
193
- const isEditingFile = (url = location) => {
194
- var _a;
195
- return Boolean(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path.startsWith("edit"));
196
- };
197
-
334
+ const isDeletingFile = (url = location) => Boolean(getRepo(url)?.path.startsWith("delete"));
335
+ const isEditingFile = (url = location) => Boolean(getRepo(url)?.path.startsWith("edit"));
198
336
  const hasFileEditor = (url = location) => isEditingFile(url) || isNewFile(url) || isDeletingFile(url);
199
-
200
- const isEditingRelease = (url = location) => {
201
- var _a;
202
- return Boolean(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path.startsWith("releases/edit"));
203
- };
204
-
337
+ const isEditingRelease = (url = location) => Boolean(getRepo(url)?.path.startsWith("releases/edit"));
205
338
  const hasReleaseEditor = (url = location) => isEditingRelease(url) || isNewRelease(url);
206
-
207
339
  const isEditingWikiPage = (url = location) => isRepoWiki(url) && getCleanPathname(url).endsWith("/_edit");
208
-
209
340
  const hasWikiPageEditor = (url = location) => isEditingWikiPage(url) || isNewWikiPage(url);
210
-
211
- const isRepo = (url = location) => /^[^/]+\/[^/]+/.test(getCleanPathname(url)) && !reservedNames.includes(url.pathname.split("/", 2)[1]) && !isDashboard(url) && !isGist(url) && !isRepoSearch(url) && !isNewRepoTemplate(url);
212
-
341
+ const isRepo = (url = location) => /^[^/]+\/[^/]+/.test(getCleanPathname(url)) && !reservedNames.includes(url.pathname.split("/", 2)[1]) && !isDashboard(url) && !isGist(url) && !isNewRepoTemplate(url);
342
+ const hasRepoHeader = (url = location) => isRepo(url) && !isRepoSearch(url);
213
343
  const isEmptyRepoRoot = () => isRepoHome() && !exists('link[rel="canonical"]');
214
-
215
344
  const isEmptyRepo = () => exists('[aria-label="Cannot fork because repository is empty."]');
216
-
217
345
  const isArchivedRepo = () => Boolean(isRepo() && $("#repository-container-header .Label").textContent.endsWith("archive"));
218
-
219
346
  const isBlank = () => exists("main .blankslate");
220
-
221
- const isRepoTaxonomyConversationList = (url = location) => {
222
- var _a;
223
- return /^labels\/.+|^milestones\/\d+(?!\/edit)/.test(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
224
- };
225
-
226
- const isRepoConversationList = (url = location) => isRepoPRList(url) || isRepoIssueList(url) || isRepoTaxonomyConversationList(url);
227
-
228
- const isRepoPRList = (url = location) => {
229
- var _a;
230
- return Boolean(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path.startsWith("pulls"));
231
- };
232
-
233
- const isRepoIssueList = (url = location) => {
234
- var _a;
235
- return /^labels\/|^issues(?!\/(\d+|new|templates)($|\/))/.test(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
236
- };
237
-
238
- const isRepoHome = (url = location) => {
239
- var _a;
240
- return "" === (null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
241
- };
242
-
243
- const isRepoRoot = url => {
244
- const repository = getRepo(null != url ? url : location);
245
- return !!repository && (!repository.path || (url ? /^tree\/[^/]+$/.test(repository.path) : repository.path.startsWith("tree/") && document.title.startsWith(repository.nameWithOwner) && !document.title.endsWith(repository.nameWithOwner)));
246
- };
247
-
248
- const isRepoSearch = (url = location) => "search" === url.pathname.split("/")[3];
249
-
250
- const isRepoSettings = (url = location) => {
251
- var _a;
252
- return Boolean(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path.startsWith("settings"));
253
- };
254
-
255
- const isRepoMainSettings = (url = location) => {
256
- var _a;
257
- return "settings" === (null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
258
- };
259
-
347
+ const isRepoTaxonomyIssueOrPRList = (url = location) => /^labels\/.+|^milestones\/\d+(?!\/edit)/.test(getRepo(url)?.path);
348
+ const isRepoIssueOrPRList = (url = location) => isRepoPRList(url) || isRepoIssueList(url) || isRepoTaxonomyIssueOrPRList(url);
349
+ const isRepoPRList = (url = location) => Boolean(getRepo(url)?.path.startsWith("pulls"));
350
+ const isRepoIssueList = (url = location) => /^labels\/|^issues(?!\/(\d+|new|templates)($|\/))/.test(getRepo(url)?.path);
351
+ const isRepoHome = (url = location) => getRepo(url)?.path === "";
352
+ const isRepoRoot = (url) => {
353
+ const repository = getRepo(url ?? location);
354
+ if (!repository) {
355
+ return false;
356
+ }
357
+ if (!repository.path) {
358
+ return true;
359
+ }
360
+ if (url) {
361
+ return /^tree\/[^/]+$/.test(repository.path);
362
+ }
363
+ return repository.path.startsWith("tree/") && document.title.startsWith(repository.nameWithOwner) && !document.title.endsWith(repository.nameWithOwner);
364
+ };
365
+ const isRepoSearch = (url = location) => getRepo(url)?.path === "search";
366
+ const isRepoSettings = (url = location) => Boolean(getRepo(url)?.path.startsWith("settings"));
367
+ const isRepoMainSettings = (url = location) => getRepo(url)?.path === "settings";
260
368
  const isRepliesSettings = (url = location) => url.pathname.startsWith("/settings/replies");
261
-
262
369
  const isUserSettings = (url = location) => url.pathname.startsWith("/settings/");
263
-
264
- const isRepoTree = (url = location) => {
265
- var _a;
266
- return isRepoRoot(url) || Boolean(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path.startsWith("tree/"));
267
- };
268
-
269
- const isRepoWiki = (url = location) => {
270
- var _a;
271
- return Boolean(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path.startsWith("wiki"));
272
- };
273
-
274
- const isSingleCommit = (url = location) => {
275
- var _a;
276
- return /^commit\/[\da-f]{5,40}$/.test(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
277
- };
278
-
279
- const isSingleFile = (url = location) => {
280
- var _a;
281
- return Boolean(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path.startsWith("blob/"));
282
- };
283
-
284
- const isFileFinder = (url = location) => {
285
- var _a;
286
- return Boolean(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path.startsWith("find/"));
287
- };
288
-
289
- const isRepoForksList = (url = location) => {
290
- var _a;
291
- return "network/members" === (null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
292
- };
293
-
294
- const isRepoNetworkGraph = (url = location) => {
295
- var _a;
296
- return "network" === (null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
297
- };
298
-
370
+ const isRepoTree = (url = location) => isRepoRoot(url) || Boolean(getRepo(url)?.path.startsWith("tree/"));
371
+ const isRepoWiki = (url = location) => Boolean(getRepo(url)?.path.startsWith("wiki"));
372
+ const isSingleCommit = (url = location) => /^commit\/[\da-f]{5,40}$/.test(getRepo(url)?.path);
373
+ const isSingleFile = (url = location) => Boolean(getRepo(url)?.path.startsWith("blob/"));
374
+ const isFileFinder = (url = location) => Boolean(getRepo(url)?.path.startsWith("find/"));
375
+ const isRepoForksList = (url = location) => getRepo(url)?.path === "network/members";
376
+ const isRepoNetworkGraph = (url = location) => getRepo(url)?.path === "network";
299
377
  const isForkedRepo = () => exists('meta[name="octolytics-dimension-repository_is_fork"][content="true"]');
300
-
301
- const isSingleGist = (url = location) => isGist(url) && /^\/(gist\/)?[^/]+\/[\da-f]{32}$/.test(url.pathname);
302
-
303
- const isGistRevision = (url = location) => isGist(url) && /^\/(gist\/)?[^/]+\/[\da-f]{32}\/revisions$/.test(url.pathname);
304
-
305
- const isTrending = (url = location) => "/trending" === url.pathname || url.pathname.startsWith("/trending/");
306
-
307
- const isBranches = (url = location) => {
308
- var _a;
309
- return Boolean(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path.startsWith("branches"));
310
- };
311
-
312
- const isProfile = (url = location) => {
313
- const pathname = getCleanPathname(url);
314
- return pathname.length > 0 && !pathname.includes("/") && !pathname.includes(".") && !reservedNames.includes(pathname);
315
- };
316
-
378
+ const isSingleGist = (url = location) => /^[^/]+\/[\da-f]{20,32}(\/[\da-f]{40})?$/.test(getCleanGistPathname(url));
379
+ const isGistRevision = (url = location) => /^[^/]+\/[\da-f]{20,32}\/revisions$/.test(getCleanGistPathname(url));
380
+ const isTrending = (url = location) => url.pathname === "/trending" || url.pathname.startsWith("/trending/");
381
+ const isBranches = (url = location) => Boolean(getRepo(url)?.path.startsWith("branches"));
382
+ const doesLookLikeAProfile = (string) => typeof string === "string" && string.length > 0 && !string.includes("/") && !string.includes(".") && !reservedNames.includes(string);
383
+ const isProfile = (url = location) => !isGist(url) && doesLookLikeAProfile(getCleanPathname(url));
384
+ const isGistProfile = (url = location) => doesLookLikeAProfile(getCleanGistPathname(url));
317
385
  const isUserProfile = () => isProfile() && !isOrganizationProfile();
318
-
319
386
  const isPrivateUserProfile = () => isUserProfile() && !exists(".user-following-container");
320
-
321
387
  const isUserProfileMainTab = () => isUserProfile() && !new URLSearchParams(location.search).has("tab");
322
-
323
- const isUserProfileRepoTab = (url = location) => isProfile(url) && "repositories" === new URLSearchParams(url.search).get("tab");
324
-
325
- const isUserProfileStarsTab = (url = location) => isProfile(url) && "stars" === new URLSearchParams(url.search).get("tab");
326
-
327
- const isUserProfileFollowersTab = (url = location) => isProfile(url) && "followers" === new URLSearchParams(url.search).get("tab");
328
-
329
- const isUserProfileFollowingTab = (url = location) => isProfile(url) && "following" === new URLSearchParams(url.search).get("tab");
330
-
331
- const hasComments = (url = location) => isPR(url) || isIssue(url) || isCommit(url) || isOrganizationDiscussion(url) || isSingleGist(url);
332
-
388
+ const isUserProfileRepoTab = (url = location) => isProfile(url) && new URLSearchParams(url.search).get("tab") === "repositories";
389
+ const isUserProfileStarsTab = (url = location) => isProfile(url) && new URLSearchParams(url.search).get("tab") === "stars";
390
+ const isUserProfileFollowersTab = (url = location) => isProfile(url) && new URLSearchParams(url.search).get("tab") === "followers";
391
+ const isUserProfileFollowingTab = (url = location) => isProfile(url) && new URLSearchParams(url.search).get("tab") === "following";
392
+ const hasComments = (url = location) => isPR(url) || isIssue(url) || isCommit(url) || isTeamDiscussion(url) || isSingleGist(url);
333
393
  const hasRichTextEditor = (url = location) => hasComments(url) || isNewIssue(url) || isCompare(url) || isRepliesSettings(url) || hasReleaseEditor(url) || isDiscussion(url);
334
-
335
394
  const hasCode = (url = location) => hasComments(url) || isRepoTree(url) || isRepoSearch(url) || isGlobalSearchResults(url) || isSingleFile(url) || isGist(url) || isCompare(url) || isCompareWikiPage(url) || isBlame(url);
336
-
337
395
  const hasFiles = (url = location) => isCommit(url) || isCompare(url) || isPRFiles(url);
338
-
339
396
  const isMarketplaceAction = (url = location) => url.pathname.startsWith("/marketplace/actions/");
340
-
341
- const isActionJobRun = (url = location) => {
342
- var _a;
343
- return Boolean(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path.startsWith("runs/"));
344
- };
345
-
346
- const isActionRun = (url = location) => {
347
- var _a;
348
- return /^(actions\/)?runs/.test(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
349
- };
350
-
351
- const isNewAction = (url = location) => {
352
- var _a;
353
- return "actions/new" === (null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
354
- };
355
-
356
- const isRepositoryActions = (url = location) => {
357
- var _a;
358
- return /^actions(\/workflows\/.+\.ya?ml)?$/.test(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
359
- };
360
-
397
+ const isActionJobRun = (url = location) => Boolean(getRepo(url)?.path.startsWith("runs/"));
398
+ const isActionRun = (url = location) => /^(actions\/)?runs/.test(getRepo(url)?.path);
399
+ const isNewAction = (url = location) => getRepo(url)?.path === "actions/new";
400
+ const isRepositoryActions = (url = location) => /^actions(\/workflows\/.+\.ya?ml)?$/.test(getRepo(url)?.path);
361
401
  const isUserTheOrganizationOwner = () => isOrganizationProfile() && exists('[aria-label="Organization"] [data-tab-item="org-header-settings-tab"]');
362
-
363
- const canUserEditOrganization = isUserTheOrganizationOwner;
364
-
365
402
  const canUserEditRepo = () => isRepo() && exists('.reponav-item[href$="/settings"], [data-tab-item$="settings-tab"]');
366
-
367
- const isNewRepo = (url = location) => "/new" === url.pathname || /^organizations\/[^/]+\/repositories\/new$/.test(getCleanPathname(url));
368
-
369
- const isNewRepoTemplate = (url = location) => Boolean("generate" === url.pathname.split("/")[3]);
370
-
371
- const getUsername = () => {
372
- var _a;
373
- return null === (_a = document.querySelector('meta[name="user-login"]')) || void 0 === _a ? void 0 : _a.getAttribute("content");
374
- };
375
-
403
+ const isNewRepo = (url = location) => url.pathname === "/new" || /^organizations\/[^/]+\/repositories\/new$/.test(getCleanPathname(url));
404
+ const isNewRepoTemplate = (url = location) => Boolean(url.pathname.split("/")[3] === "generate");
405
+ const getUsername = () => document.querySelector('meta[name="user-login"]')?.getAttribute("content");
376
406
  const getCleanPathname = (url = location) => url.pathname.replace(/\/+/g, "/").slice(1, url.pathname.endsWith("/") ? -1 : void 0);
377
-
378
- const getRepo = url => {
379
- if (!url) {
380
- const canonical = document.querySelector('[property="og:url"]');
381
- if (canonical) {
382
- const canonicalUrl = new URL(canonical.content, location.origin);
383
- getCleanPathname(canonicalUrl).toLowerCase() === getCleanPathname(location).toLowerCase() && (url = canonicalUrl);
384
- }
407
+ const getCleanGistPathname = (url = location) => {
408
+ const pathname = getCleanPathname(url);
409
+ if (url.hostname.startsWith("gist.")) {
410
+ return pathname;
411
+ }
412
+ const [gist, ...parts] = pathname.split("/");
413
+ return gist === "gist" ? parts.join("/") : void 0;
414
+ };
415
+ const getRepo = (url) => {
416
+ if (!url) {
417
+ const canonical = document.querySelector('[property="og:url"]');
418
+ if (canonical) {
419
+ const canonicalUrl = new URL(canonical.content, location.origin);
420
+ if (getCleanPathname(canonicalUrl).toLowerCase() === getCleanPathname(location).toLowerCase()) {
421
+ url = canonicalUrl;
422
+ }
385
423
  }
386
- "string" == typeof url && (url = new URL(url, location.origin));
387
- if (!isRepo(url)) return;
388
- const [owner, name, ...path] = getCleanPathname(url).split("/");
389
- return {
390
- owner: owner,
391
- name: name,
392
- nameWithOwner: owner + "/" + name,
393
- path: path.join("/")
394
- };
424
+ }
425
+ if (typeof url === "string") {
426
+ url = new URL(url, location.origin);
427
+ }
428
+ if (!isRepo(url)) {
429
+ return;
430
+ }
431
+ const [owner, name, ...path] = getCleanPathname(url).split("/");
432
+ return {
433
+ owner,
434
+ name,
435
+ nameWithOwner: owner + "/" + name,
436
+ path: path.join("/")
437
+ };
395
438
  };
396
-
397
439
  const utils = {
398
- getUsername: getUsername,
399
- getCleanPathname: getCleanPathname,
400
- getRepositoryInfo: getRepo
440
+ getUsername,
441
+ getCleanPathname,
442
+ getCleanGistPathname,
443
+ getRepositoryInfo: getRepo
444
+ };
445
+ export {
446
+ canUserEditRepo,
447
+ hasCode,
448
+ hasComments,
449
+ hasFileEditor,
450
+ hasFiles,
451
+ hasReleaseEditor,
452
+ hasRepoHeader,
453
+ hasRichTextEditor,
454
+ hasWikiPageEditor,
455
+ is404,
456
+ is500,
457
+ isActionJobRun,
458
+ isActionRun,
459
+ isArchivedRepo,
460
+ isBlame,
461
+ isBlank,
462
+ isBranches,
463
+ isClosedIssue,
464
+ isClosedPR,
465
+ isCommit,
466
+ isCommitList,
467
+ isCompare,
468
+ isCompareWikiPage,
469
+ isConversation,
470
+ isDashboard,
471
+ isDeletingFile,
472
+ isDiscussion,
473
+ isDiscussionList,
474
+ isDraftPR,
475
+ isEditingFile,
476
+ isEditingRelease,
477
+ isEditingWikiPage,
478
+ isEmptyRepo,
479
+ isEmptyRepoRoot,
480
+ isEnterprise,
481
+ isFileFinder,
482
+ isForkedRepo,
483
+ isGist,
484
+ isGistProfile,
485
+ isGistRevision,
486
+ isGlobalIssueOrPRList,
487
+ isGlobalSearchResults,
488
+ isIssue,
489
+ isIssueOrPRList,
490
+ isLabelList,
491
+ isMarketplaceAction,
492
+ isMergedPR,
493
+ isMilestone,
494
+ isMilestoneList,
495
+ isNewAction,
496
+ isNewFile,
497
+ isNewIssue,
498
+ isNewRelease,
499
+ isNewRepo,
500
+ isNewRepoTemplate,
501
+ isNewWikiPage,
502
+ isNotifications,
503
+ isOpenPR,
504
+ isOrganizationProfile,
505
+ isOrganizationRepo,
506
+ isOwnOrganizationProfile,
507
+ isOwnUserProfile,
508
+ isPR,
509
+ isPRCommit,
510
+ isPRCommit404,
511
+ isPRCommitList,
512
+ isPRConflicts,
513
+ isPRConversation,
514
+ isPRFile404,
515
+ isPRFiles,
516
+ isPRList,
517
+ isPasswordConfirmation,
518
+ isPrivateUserProfile,
519
+ isProfile,
520
+ isProject,
521
+ isProjects,
522
+ isQuickPR,
523
+ isReleases,
524
+ isReleasesOrTags,
525
+ isRepliesSettings,
526
+ isRepo,
527
+ isRepoCommitList,
528
+ isRepoForksList,
529
+ isRepoHome,
530
+ isRepoIssueList,
531
+ isRepoIssueOrPRList,
532
+ isRepoMainSettings,
533
+ isRepoNetworkGraph,
534
+ isRepoPRList,
535
+ isRepoRoot,
536
+ isRepoSearch,
537
+ isRepoSettings,
538
+ isRepoTaxonomyIssueOrPRList,
539
+ isRepoTree,
540
+ isRepoWiki,
541
+ isRepositoryActions,
542
+ isSingleCommit,
543
+ isSingleFile,
544
+ isSingleGist,
545
+ isSingleTag,
546
+ isTags,
547
+ isTeamDiscussion,
548
+ isTrending,
549
+ isUserProfile,
550
+ isUserProfileFollowersTab,
551
+ isUserProfileFollowingTab,
552
+ isUserProfileMainTab,
553
+ isUserProfileRepoTab,
554
+ isUserProfileStarsTab,
555
+ isUserSettings,
556
+ isUserTheOrganizationOwner,
557
+ utils
401
558
  };
402
-
403
- export { canUserEditOrganization, canUserEditRepo, hasCode, hasComments, hasFileEditor, hasFiles, hasReleaseEditor, hasRichTextEditor, hasWikiPageEditor, is404, is500, isActionJobRun, isActionRun, isArchivedRepo, isBlame, isBlank, isBranches, isClosedConversation, isClosedPR, isCommit, isCommitList, isCompare, isCompareWikiPage, isConversation, isConversationList, isDashboard, isDeletingFile, isDiscussion, isDiscussionList, isDraftPR, isEditingFile, isEditingRelease, isEditingWikiPage, isEmptyRepo, isEmptyRepoRoot, isEnterprise, isFileFinder, isForkedRepo, isGist, isGistRevision, isGlobalConversationList, isGlobalSearchResults, isIssue, isLabelList, isMarketplaceAction, isMergedPR, isMilestone, isMilestoneList, isNewAction, isNewFile, isNewIssue, isNewRelease, isNewRepo, isNewRepoTemplate, isNewWikiPage, isNotifications, isOpenPR, isOrganizationDiscussion, isOrganizationProfile, isOrganizationRepo, isOwnOrganizationProfile, isOwnUserProfile, isPR, isPRCommit, isPRCommit404, isPRCommitList, isPRConflicts, isPRConversation, isPRFile404, isPRFiles, isPRList, isPasswordConfirmation, isPrivateUserProfile, isProfile, isProject, isProjects, isQuickPR, isReleases, isReleasesOrTags, isRepliesSettings, isRepo, isRepoCommitList, isRepoConversationList, isRepoForksList, isRepoHome, isRepoIssueList, isRepoMainSettings, isRepoNetworkGraph, isRepoPRList, isRepoRoot, isRepoSearch, isRepoSettings, isRepoTaxonomyConversationList, isRepoTree, isRepoWiki, isRepositoryActions, isSingleCommit, isSingleFile, isSingleGist, isSingleTag, isTags, isTrending, isUserProfile, isUserProfileFollowersTab, isUserProfileFollowingTab, isUserProfileMainTab, isUserProfileRepoTab, isUserProfileStarsTab, isUserSettings, isUserTheOrganizationOwner, utils };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "github-url-detection",
3
- "version": "5.13.0",
3
+ "version": "6.0.0",
4
4
  "description": "Which GitHub page are you on? Is it an issue? Is it a list? Perfect for your WebExtension or userscript.",
5
5
  "keywords": [
6
6
  "github",
@@ -22,32 +22,25 @@
22
22
  "distribution/index.js",
23
23
  "distribution/index.d.ts"
24
24
  ],
25
- "alias": {
26
- "./this-stuff-is-just-for-local-parcel-tests": "./package.json",
27
- "./collector.js": "./collector.ts"
28
- },
29
25
  "scripts": {
30
26
  "ava": "ava --timeout 30s",
31
- "build": "rollup -c",
32
- "demo:build": "parcel build --public-url ./ --out-dir demo/dist demo/index.html",
27
+ "build": "run-p build:*",
28
+ "build:vite": "vite build",
29
+ "build:typescript": "tsc --declaration --emitDeclarationOnly",
30
+ "demo:build": "vite build demo --config demo/vite.config.js",
33
31
  "demo:test": "svelte-check",
34
- "demo:watch": "parcel --out-dir demo/dist demo/index.html",
35
- "prepack": "rollup -c",
32
+ "demo:watch": "vite serve demo --config demo/vite.config.js",
33
+ "prepack": "vite build",
36
34
  "test": "run-p build ava xo",
37
- "watch": "rollup -c --watch",
35
+ "watch": "run-p watch:typescript demo:watch # vite watch doesn’t generate the lib, so just use the demo",
36
+ "watch:typescript": "tsc --watch --noEmit",
37
+ "watch:ava": "run-p 'ava -- --watch' 'watch:typescript -- --watch'",
38
38
  "xo": "xo"
39
39
  },
40
- "browserslist": [
41
- "last 2 versions",
42
- "not IE <= 11"
43
- ],
44
40
  "xo": {
45
41
  "envs": [
46
42
  "browser"
47
43
  ],
48
- "ignore": [
49
- "demo"
50
- ],
51
44
  "overrides": [
52
45
  {
53
46
  "files": [
@@ -59,7 +52,8 @@
59
52
  "@typescript-eslint/no-non-null-assertion": "off",
60
53
  "@typescript-eslint/no-unsafe-member-access": "off",
61
54
  "@typescript-eslint/no-non-null-asserted-optional-chain": "off",
62
- "@typescript-eslint/naming-convention": "off"
55
+ "@typescript-eslint/naming-convention": "off",
56
+ "n/prefer-global/process": "off"
63
57
  }
64
58
  }
65
59
  ],
@@ -68,44 +62,30 @@
68
62
  }
69
63
  },
70
64
  "ava": {
71
- "environmentVariables": {
72
- "TS_NODE_FILES": "true"
73
- },
74
65
  "extensions": {
75
66
  "ts": "module"
76
67
  },
77
68
  "nodeArguments": [
78
- "--loader=ts-node/esm",
69
+ "--loader=esbuild-node-loader",
79
70
  "--experimental-specifier-resolution=node"
80
- ],
81
- "nonSemVerExperiments": {
82
- "configurableModuleFormat": true
83
- }
71
+ ]
84
72
  },
85
73
  "devDependencies": {
86
- "@rollup/plugin-json": "^4.1.0",
87
- "@rollup/plugin-node-resolve": "^13.0.6",
88
- "@rollup/plugin-typescript": "^8.3.0",
89
- "@sindresorhus/tsconfig": "^2.0.0",
90
- "@types/estree": "^0.0.50",
91
- "@types/jsdom": "^16.2.13",
92
- "ava": "^3.15.0",
74
+ "@sindresorhus/tsconfig": "^3.0.1",
75
+ "@sveltejs/vite-plugin-svelte": "^1.0.1",
76
+ "ava": "^4.3.1",
77
+ "esbuild-node-loader": "^0.8.0",
93
78
  "github-reserved-names": "^2.0.4",
94
- "jsdom": "^19.0.0",
95
79
  "npm-run-all": "^4.1.5",
96
- "parcel-bundler": "^1.12.4",
97
- "parcel-plugin-svelte": "^4.0.9",
98
- "rollup": "^2.60.2",
99
- "rollup-plugin-terser": "^7.0.2",
100
80
  "strip-indent": "^4.0.0",
101
- "svelte": "^3.44.2",
102
- "svelte-check": "^2.2.10",
103
- "ts-node": "^10.4.0",
104
- "tslib": "^2.3.1",
105
- "typescript": "^4.5.2",
106
- "xo": "^0.47.0"
81
+ "svelte": "^3.49.0",
82
+ "svelte-check": "^2.8.0",
83
+ "tslib": "^2.4.0",
84
+ "typescript": "^4.7.4",
85
+ "vite": "^3.0.2",
86
+ "xo": "^0.51.0"
107
87
  },
108
88
  "engines": {
109
- "node": ">=12"
89
+ "node": ">=14"
110
90
  }
111
91
  }
package/readme.md CHANGED
@@ -30,7 +30,7 @@ if (pageDetect.isRepo()) { // Uses `window.location.href` by default
30
30
  alert('You’re looking at a repo!')
31
31
  }
32
32
 
33
- if (pageDetect.isConversationList()) {
33
+ if (pageDetect.isIssueOrPRList()) {
34
34
  alert('You’re looking at a issues and PRs list!')
35
35
  }
36
36
  ```
@@ -44,13 +44,13 @@ Most detections are URL-based while others need access to the current `document`
44
44
  By default, URL-based detections use the `location` global if you don't pass a `url` argument.
45
45
 
46
46
  ```js
47
- if (pageDetect.isConversationList()) {
47
+ if (pageDetect.isIssueOrPRList()) {
48
48
  alert('You’re looking at a issues or PRs list!')
49
49
  }
50
50
  ```
51
51
 
52
52
  ```js
53
- if (pageDetect.isConversationList(new URL('https://github.com/refined-github/github-url-detection/pulls'))) {
53
+ if (pageDetect.isIssueOrPRList(new URL('https://github.com/refined-github/github-url-detection/pulls'))) {
54
54
  alert('You’re looking at a issues or PRs list!')
55
55
  }
56
56
  ```
@@ -1,129 +0,0 @@
1
- export declare const is404: () => boolean;
2
- export declare const is500: () => boolean;
3
- export declare const isPasswordConfirmation: () => boolean;
4
- export declare const isBlame: (url?: URL | HTMLAnchorElement | Location) => boolean;
5
- export declare const isCommit: (url?: URL | HTMLAnchorElement | Location) => boolean;
6
- export declare const isCommitList: (url?: URL | HTMLAnchorElement | Location) => boolean;
7
- export declare const isRepoCommitList: (url?: URL | HTMLAnchorElement | Location) => boolean;
8
- export declare const isCompare: (url?: URL | HTMLAnchorElement | Location) => boolean;
9
- export declare const isCompareWikiPage: (url?: URL | HTMLAnchorElement | Location) => boolean;
10
- export declare const isDashboard: (url?: URL | HTMLAnchorElement | Location) => boolean;
11
- export declare const isEnterprise: (url?: URL | HTMLAnchorElement | Location) => boolean;
12
- export declare const isGist: (url?: URL | HTMLAnchorElement | Location) => boolean;
13
- export declare const isGlobalConversationList: (url?: URL | HTMLAnchorElement | Location) => boolean;
14
- export declare const isGlobalSearchResults: (url?: URL | HTMLAnchorElement | Location) => boolean;
15
- export declare const isIssue: (url?: URL | HTMLAnchorElement | Location) => boolean;
16
- export declare const isConversationList: (url?: URL | HTMLAnchorElement | Location) => boolean;
17
- export declare const isConversation: (url?: URL | HTMLAnchorElement | Location) => boolean;
18
- export declare const isLabelList: (url?: URL | HTMLAnchorElement | Location) => boolean;
19
- export declare const isMilestone: (url?: URL | HTMLAnchorElement | Location) => boolean;
20
- export declare const isMilestoneList: (url?: URL | HTMLAnchorElement | Location) => boolean;
21
- export declare const isNewFile: (url?: URL | HTMLAnchorElement | Location) => boolean;
22
- export declare const isNewIssue: (url?: URL | HTMLAnchorElement | Location) => boolean;
23
- export declare const isNewRelease: (url?: URL | HTMLAnchorElement | Location) => boolean;
24
- export declare const isNewWikiPage: (url?: URL | HTMLAnchorElement | Location) => boolean;
25
- export declare const isNotifications: (url?: URL | HTMLAnchorElement | Location) => boolean;
26
- export declare const isOrganizationProfile: () => boolean;
27
- export declare const isOrganizationRepo: () => boolean;
28
- export declare const isOrganizationDiscussion: (url?: URL | HTMLAnchorElement | Location) => boolean;
29
- export declare const isOwnUserProfile: () => boolean;
30
- export declare const isOwnOrganizationProfile: () => boolean;
31
- export declare const isProject: (url?: URL | HTMLAnchorElement | Location) => boolean;
32
- export declare const isProjects: (url?: URL | HTMLAnchorElement | Location) => boolean;
33
- export declare const isDiscussion: (url?: URL | HTMLAnchorElement | Location) => boolean;
34
- export declare const isDiscussionList: (url?: URL | HTMLAnchorElement | Location) => boolean;
35
- export declare const isPR: (url?: URL | HTMLAnchorElement | Location) => boolean;
36
- export declare const isPRConflicts: (url?: URL | HTMLAnchorElement | Location) => boolean;
37
- /** Any `isConversationList` can display both issues and PRs, prefer that detection. `isPRList` only exists because this page has PR-specific filters like the "Reviews" dropdown */
38
- export declare const isPRList: (url?: URL | HTMLAnchorElement | Location) => boolean;
39
- export declare const isPRCommit: (url?: URL | HTMLAnchorElement | Location) => boolean;
40
- export declare const isPRCommit404: () => boolean;
41
- export declare const isPRFile404: () => boolean;
42
- export declare const isPRConversation: (url?: URL | HTMLAnchorElement | Location) => boolean;
43
- export declare const isPRCommitList: (url?: URL | HTMLAnchorElement | Location) => boolean;
44
- export declare const isPRFiles: (url?: URL | HTMLAnchorElement | Location) => boolean;
45
- export declare const isQuickPR: (url?: URL | HTMLAnchorElement | Location) => boolean;
46
- export declare const isDraftPR: () => boolean;
47
- export declare const isOpenPR: () => boolean;
48
- export declare const isMergedPR: () => boolean;
49
- export declare const isClosedConversation: () => boolean;
50
- /** @deprecated Use isClosedConversation */
51
- export declare const isClosedPR: () => boolean;
52
- export declare const isReleases: (url?: URL | HTMLAnchorElement | Location) => boolean;
53
- export declare const isTags: (url?: URL | HTMLAnchorElement | Location) => boolean;
54
- export declare const isSingleTag: (url?: URL | HTMLAnchorElement | Location) => boolean;
55
- export declare const isReleasesOrTags: (url?: URL | HTMLAnchorElement | Location) => boolean;
56
- export declare const isDeletingFile: (url?: URL | HTMLAnchorElement | Location) => boolean;
57
- export declare const isEditingFile: (url?: URL | HTMLAnchorElement | Location) => boolean;
58
- export declare const hasFileEditor: (url?: URL | HTMLAnchorElement | Location) => boolean;
59
- export declare const isEditingRelease: (url?: URL | HTMLAnchorElement | Location) => boolean;
60
- export declare const hasReleaseEditor: (url?: URL | HTMLAnchorElement | Location) => boolean;
61
- export declare const isEditingWikiPage: (url?: URL | HTMLAnchorElement | Location) => boolean;
62
- export declare const hasWikiPageEditor: (url?: URL | HTMLAnchorElement | Location) => boolean;
63
- export declare const isRepo: (url?: URL | HTMLAnchorElement | Location) => boolean;
64
- export declare const isEmptyRepoRoot: () => boolean;
65
- export declare const isEmptyRepo: () => boolean;
66
- export declare const isArchivedRepo: () => boolean;
67
- export declare const isBlank: () => boolean;
68
- export declare const isRepoTaxonomyConversationList: (url?: URL | HTMLAnchorElement | Location) => boolean;
69
- export declare const isRepoConversationList: (url?: URL | HTMLAnchorElement | Location) => boolean;
70
- export declare const isRepoPRList: (url?: URL | HTMLAnchorElement | Location) => boolean;
71
- export declare const isRepoIssueList: (url?: URL | HTMLAnchorElement | Location) => boolean;
72
- export declare const isRepoHome: (url?: URL | HTMLAnchorElement | Location) => boolean;
73
- export declare const isRepoRoot: (url?: URL | HTMLAnchorElement | Location | undefined) => boolean;
74
- export declare const isRepoSearch: (url?: URL | HTMLAnchorElement | Location) => boolean;
75
- export declare const isRepoSettings: (url?: URL | HTMLAnchorElement | Location) => boolean;
76
- export declare const isRepoMainSettings: (url?: URL | HTMLAnchorElement | Location) => boolean;
77
- export declare const isRepliesSettings: (url?: URL | HTMLAnchorElement | Location) => boolean;
78
- export declare const isUserSettings: (url?: URL | HTMLAnchorElement | Location) => boolean;
79
- export declare const isRepoTree: (url?: URL | HTMLAnchorElement | Location) => boolean;
80
- export declare const isRepoWiki: (url?: URL | HTMLAnchorElement | Location) => boolean;
81
- export declare const isSingleCommit: (url?: URL | HTMLAnchorElement | Location) => boolean;
82
- export declare const isSingleFile: (url?: URL | HTMLAnchorElement | Location) => boolean;
83
- export declare const isFileFinder: (url?: URL | HTMLAnchorElement | Location) => boolean;
84
- export declare const isRepoForksList: (url?: URL | HTMLAnchorElement | Location) => boolean;
85
- export declare const isRepoNetworkGraph: (url?: URL | HTMLAnchorElement | Location) => boolean;
86
- export declare const isForkedRepo: () => boolean;
87
- export declare const isSingleGist: (url?: URL | HTMLAnchorElement | Location) => boolean;
88
- export declare const isGistRevision: (url?: URL | HTMLAnchorElement | Location) => boolean;
89
- export declare const isTrending: (url?: URL | HTMLAnchorElement | Location) => boolean;
90
- export declare const isBranches: (url?: URL | HTMLAnchorElement | Location) => boolean;
91
- export declare const isProfile: (url?: URL | HTMLAnchorElement | Location) => boolean;
92
- export declare const isUserProfile: () => boolean;
93
- export declare const isPrivateUserProfile: () => boolean;
94
- export declare const isUserProfileMainTab: () => boolean;
95
- export declare const isUserProfileRepoTab: (url?: URL | HTMLAnchorElement | Location) => boolean;
96
- export declare const isUserProfileStarsTab: (url?: URL | HTMLAnchorElement | Location) => boolean;
97
- export declare const isUserProfileFollowersTab: (url?: URL | HTMLAnchorElement | Location) => boolean;
98
- export declare const isUserProfileFollowingTab: (url?: URL | HTMLAnchorElement | Location) => boolean;
99
- export declare const hasComments: (url?: URL | HTMLAnchorElement | Location) => boolean;
100
- export declare const hasRichTextEditor: (url?: URL | HTMLAnchorElement | Location) => boolean;
101
- export declare const hasCode: (url?: URL | HTMLAnchorElement | Location) => boolean;
102
- export declare const hasFiles: (url?: URL | HTMLAnchorElement | Location) => boolean;
103
- export declare const isMarketplaceAction: (url?: URL | HTMLAnchorElement | Location) => boolean;
104
- export declare const isActionJobRun: (url?: URL | HTMLAnchorElement | Location) => boolean;
105
- export declare const isActionRun: (url?: URL | HTMLAnchorElement | Location) => boolean;
106
- export declare const isNewAction: (url?: URL | HTMLAnchorElement | Location) => boolean;
107
- export declare const isRepositoryActions: (url?: URL | HTMLAnchorElement | Location) => boolean;
108
- export declare const isUserTheOrganizationOwner: () => boolean;
109
- /** @deprecated use isUserTheOrganizationOwner instead */
110
- export declare const canUserEditOrganization: () => boolean;
111
- export declare const canUserEditRepo: () => boolean;
112
- export declare const isNewRepo: (url?: URL | HTMLAnchorElement | Location) => boolean;
113
- export declare const isNewRepoTemplate: (url?: URL | HTMLAnchorElement | Location) => boolean;
114
- export interface RepositoryInfo {
115
- owner: string;
116
- name: string;
117
- /** The 'user/repo' part from an URL */
118
- nameWithOwner: string;
119
- /** A repo's subpage
120
- @example '/user/repo/issues/' -> 'issues'
121
- @example '/user/repo/' -> ''
122
- @example '/settings/token/' -> undefined */
123
- path: string;
124
- }
125
- export declare const utils: {
126
- getUsername: () => string | undefined;
127
- getCleanPathname: (url?: URL | HTMLAnchorElement | Location) => string;
128
- getRepositoryInfo: (url?: string | URL | HTMLAnchorElement | Location | undefined) => RepositoryInfo | undefined;
129
- };