github-url-detection 5.12.1 → 6.0.1

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.
@@ -10,10 +10,10 @@ export declare const isCompareWikiPage: (url?: URL | HTMLAnchorElement | Locatio
10
10
  export declare const isDashboard: (url?: URL | HTMLAnchorElement | Location) => boolean;
11
11
  export declare const isEnterprise: (url?: URL | HTMLAnchorElement | Location) => boolean;
12
12
  export declare const isGist: (url?: URL | HTMLAnchorElement | Location) => boolean;
13
- export declare const isGlobalConversationList: (url?: URL | HTMLAnchorElement | Location) => boolean;
13
+ export declare const isGlobalIssueOrPRList: (url?: URL | HTMLAnchorElement | Location) => boolean;
14
14
  export declare const isGlobalSearchResults: (url?: URL | HTMLAnchorElement | Location) => boolean;
15
15
  export declare const isIssue: (url?: URL | HTMLAnchorElement | Location) => boolean;
16
- export declare const isConversationList: (url?: URL | HTMLAnchorElement | Location) => boolean;
16
+ export declare const isIssueOrPRList: (url?: URL | HTMLAnchorElement | Location) => boolean;
17
17
  export declare const isConversation: (url?: URL | HTMLAnchorElement | Location) => boolean;
18
18
  export declare const isLabelList: (url?: URL | HTMLAnchorElement | Location) => boolean;
19
19
  export declare const isMilestone: (url?: URL | HTMLAnchorElement | Location) => boolean;
@@ -25,7 +25,7 @@ export declare const isNewWikiPage: (url?: URL | HTMLAnchorElement | Location) =
25
25
  export declare const isNotifications: (url?: URL | HTMLAnchorElement | Location) => boolean;
26
26
  export declare const isOrganizationProfile: () => boolean;
27
27
  export declare const isOrganizationRepo: () => boolean;
28
- export declare const isOrganizationDiscussion: (url?: URL | HTMLAnchorElement | Location) => boolean;
28
+ export declare const isTeamDiscussion: (url?: URL | HTMLAnchorElement | Location) => boolean;
29
29
  export declare const isOwnUserProfile: () => boolean;
30
30
  export declare const isOwnOrganizationProfile: () => boolean;
31
31
  export declare const isProject: (url?: URL | HTMLAnchorElement | Location) => boolean;
@@ -34,7 +34,7 @@ export declare const isDiscussion: (url?: URL | HTMLAnchorElement | Location) =>
34
34
  export declare const isDiscussionList: (url?: URL | HTMLAnchorElement | Location) => boolean;
35
35
  export declare const isPR: (url?: URL | HTMLAnchorElement | Location) => boolean;
36
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 */
37
+ /** Any `isIssueOrPRList` can display both issues and PRs, prefer that detection. `isPRList` only exists because this page has PR-specific filters like the "Reviews" dropdown */
38
38
  export declare const isPRList: (url?: URL | HTMLAnchorElement | Location) => boolean;
39
39
  export declare const isPRCommit: (url?: URL | HTMLAnchorElement | Location) => boolean;
40
40
  export declare const isPRCommit404: () => boolean;
@@ -46,9 +46,8 @@ export declare const isQuickPR: (url?: URL | HTMLAnchorElement | Location) => bo
46
46
  export declare const isDraftPR: () => boolean;
47
47
  export declare const isOpenPR: () => boolean;
48
48
  export declare const isMergedPR: () => boolean;
49
- export declare const isClosedConversation: () => boolean;
50
- /** @deprecated Use isClosedConversation */
51
49
  export declare const isClosedPR: () => boolean;
50
+ export declare const isClosedIssue: () => boolean;
52
51
  export declare const isReleases: (url?: URL | HTMLAnchorElement | Location) => boolean;
53
52
  export declare const isTags: (url?: URL | HTMLAnchorElement | Location) => boolean;
54
53
  export declare const isSingleTag: (url?: URL | HTMLAnchorElement | Location) => boolean;
@@ -61,15 +60,17 @@ export declare const hasReleaseEditor: (url?: URL | HTMLAnchorElement | Location
61
60
  export declare const isEditingWikiPage: (url?: URL | HTMLAnchorElement | Location) => boolean;
62
61
  export declare const hasWikiPageEditor: (url?: URL | HTMLAnchorElement | Location) => boolean;
63
62
  export declare const isRepo: (url?: URL | HTMLAnchorElement | Location) => boolean;
63
+ export declare const hasRepoHeader: (url?: URL | HTMLAnchorElement | Location) => boolean;
64
64
  export declare const isEmptyRepoRoot: () => boolean;
65
65
  export declare const isEmptyRepo: () => boolean;
66
+ export declare const isArchivedRepo: () => boolean;
66
67
  export declare const isBlank: () => boolean;
67
- export declare const isRepoTaxonomyConversationList: (url?: URL | HTMLAnchorElement | Location) => boolean;
68
- export declare const isRepoConversationList: (url?: URL | HTMLAnchorElement | Location) => boolean;
68
+ export declare const isRepoTaxonomyIssueOrPRList: (url?: URL | HTMLAnchorElement | Location) => boolean;
69
+ export declare const isRepoIssueOrPRList: (url?: URL | HTMLAnchorElement | Location) => boolean;
69
70
  export declare const isRepoPRList: (url?: URL | HTMLAnchorElement | Location) => boolean;
70
71
  export declare const isRepoIssueList: (url?: URL | HTMLAnchorElement | Location) => boolean;
71
72
  export declare const isRepoHome: (url?: URL | HTMLAnchorElement | Location) => boolean;
72
- export declare const isRepoRoot: (url?: URL | HTMLAnchorElement | Location | undefined) => boolean;
73
+ export declare const isRepoRoot: (url?: URL | HTMLAnchorElement | Location) => boolean;
73
74
  export declare const isRepoSearch: (url?: URL | HTMLAnchorElement | Location) => boolean;
74
75
  export declare const isRepoSettings: (url?: URL | HTMLAnchorElement | Location) => boolean;
75
76
  export declare const isRepoMainSettings: (url?: URL | HTMLAnchorElement | Location) => boolean;
@@ -88,7 +89,9 @@ export declare const isGistRevision: (url?: URL | HTMLAnchorElement | Location)
88
89
  export declare const isTrending: (url?: URL | HTMLAnchorElement | Location) => boolean;
89
90
  export declare const isBranches: (url?: URL | HTMLAnchorElement | Location) => boolean;
90
91
  export declare const isProfile: (url?: URL | HTMLAnchorElement | Location) => boolean;
92
+ export declare const isGistProfile: (url?: URL | HTMLAnchorElement | Location) => boolean;
91
93
  export declare const isUserProfile: () => boolean;
94
+ export declare const isPrivateUserProfile: () => boolean;
92
95
  export declare const isUserProfileMainTab: () => boolean;
93
96
  export declare const isUserProfileRepoTab: (url?: URL | HTMLAnchorElement | Location) => boolean;
94
97
  export declare const isUserProfileStarsTab: (url?: URL | HTMLAnchorElement | Location) => boolean;
@@ -96,7 +99,9 @@ export declare const isUserProfileFollowersTab: (url?: URL | HTMLAnchorElement |
96
99
  export declare const isUserProfileFollowingTab: (url?: URL | HTMLAnchorElement | Location) => boolean;
97
100
  export declare const hasComments: (url?: URL | HTMLAnchorElement | Location) => boolean;
98
101
  export declare const hasRichTextEditor: (url?: URL | HTMLAnchorElement | Location) => boolean;
102
+ /** Static code, not the code editor */
99
103
  export declare const hasCode: (url?: URL | HTMLAnchorElement | Location) => boolean;
104
+ /** Has a list of files */
100
105
  export declare const hasFiles: (url?: URL | HTMLAnchorElement | Location) => boolean;
101
106
  export declare const isMarketplaceAction: (url?: URL | HTMLAnchorElement | Location) => boolean;
102
107
  export declare const isActionJobRun: (url?: URL | HTMLAnchorElement | Location) => boolean;
@@ -104,8 +109,6 @@ export declare const isActionRun: (url?: URL | HTMLAnchorElement | Location) =>
104
109
  export declare const isNewAction: (url?: URL | HTMLAnchorElement | Location) => boolean;
105
110
  export declare const isRepositoryActions: (url?: URL | HTMLAnchorElement | Location) => boolean;
106
111
  export declare const isUserTheOrganizationOwner: () => boolean;
107
- /** @deprecated use isUserTheOrganizationOwner instead */
108
- export declare const canUserEditOrganization: () => boolean;
109
112
  export declare const canUserEditRepo: () => boolean;
110
113
  export declare const isNewRepo: (url?: URL | HTMLAnchorElement | Location) => boolean;
111
114
  export declare const isNewRepoTemplate: (url?: URL | HTMLAnchorElement | Location) => boolean;
@@ -123,5 +126,6 @@ export interface RepositoryInfo {
123
126
  export declare const utils: {
124
127
  getUsername: () => string | undefined;
125
128
  getCleanPathname: (url?: URL | HTMLAnchorElement | Location) => string;
126
- getRepositoryInfo: (url?: string | URL | HTMLAnchorElement | Location | undefined) => RepositoryInfo | undefined;
129
+ getCleanGistPathname: (url?: URL | HTMLAnchorElement | Location) => string | undefined;
130
+ getRepositoryInfo: (url?: URL | HTMLAnchorElement | Location | string) => RepositoryInfo | undefined;
127
131
  };
@@ -1,397 +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 exists = selector => Boolean(document.querySelector(selector));
4
-
5
- const is404 = () => document.title.startsWith("Page not found · GitHub");
6
-
7
- const is500 = () => "Server Error · GitHub" === document.title || "Unicorn! · GitHub" === document.title || "504 Gateway Time-out" === document.title;
8
-
9
- const isPasswordConfirmation = () => "Confirm password" === document.title || "Confirm access" === document.title;
10
-
11
- const isBlame = (url = location) => {
12
- var _a;
13
- return Boolean(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path.startsWith("blame/"));
14
- };
15
-
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/"));
16
285
  const isCommit = (url = location) => isSingleCommit(url) || isPRCommit(url);
17
-
18
286
  const isCommitList = (url = location) => isRepoCommitList(url) || isPRCommitList(url);
19
-
20
- const isRepoCommitList = (url = location) => {
21
- var _a;
22
- return Boolean(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path.startsWith("commits"));
23
- };
24
-
25
- const isCompare = (url = location) => {
26
- var _a;
27
- return Boolean(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path.startsWith("compare"));
28
- };
29
-
287
+ const isRepoCommitList = (url = location) => Boolean(getRepo(url)?.path.startsWith("commits"));
288
+ const isCompare = (url = location) => Boolean(getRepo(url)?.path.startsWith("compare"));
30
289
  const isCompareWikiPage = (url = location) => isRepoWiki(url) && getCleanPathname(url).split("/").slice(3, 5).includes("_compare");
31
-
32
290
  const isDashboard = (url = location) => !isGist(url) && /^$|^(orgs\/[^/]+\/)?dashboard(\/|$)/.test(getCleanPathname(url));
33
-
34
- const isEnterprise = (url = location) => "github.com" !== url.hostname && "gist.github.com" !== url.hostname;
35
-
36
- const isGist = (url = location) => url.hostname.startsWith("gist.") || "gist" === url.pathname.split("/", 2)[1];
37
-
38
- const isGlobalConversationList = (url = location) => [ "issues", "pulls" ].includes(url.pathname.split("/", 2)[1]);
39
-
40
- const isGlobalSearchResults = (url = location) => "/search" === url.pathname && null !== new URLSearchParams(url.search).get("q");
41
-
42
- const isIssue = (url = location) => {
43
- var _a;
44
- return /^issues\/\d+/.test(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path) && "GitHub · Where software is built" !== document.title;
45
- };
46
-
47
- const isConversationList = (url = location) => isGlobalConversationList(url) || isRepoConversationList(url) || isMilestone(url);
48
-
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);
49
297
  const isConversation = (url = location) => isIssue(url) || isPRConversation(url);
50
-
51
- const isLabelList = (url = location) => {
52
- var _a;
53
- return "labels" === (null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
54
- };
55
-
56
- const isMilestone = (url = location) => {
57
- var _a;
58
- return /^milestone\/\d+/.test(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
59
- };
60
-
61
- const isMilestoneList = (url = location) => {
62
- var _a;
63
- return "milestones" === (null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
64
- };
65
-
66
- const isNewFile = (url = location) => {
67
- var _a;
68
- return Boolean(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path.startsWith("new"));
69
- };
70
-
71
- const isNewIssue = (url = location) => {
72
- var _a;
73
- return "issues/new" === (null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
74
- };
75
-
76
- const isNewRelease = (url = location) => {
77
- var _a;
78
- return "releases/new" === (null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
79
- };
80
-
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";
81
304
  const isNewWikiPage = (url = location) => isRepoWiki(url) && getCleanPathname(url).endsWith("/_new");
82
-
83
- const isNotifications = (url = location) => "notifications" === getCleanPathname(url);
84
-
305
+ const isNotifications = (url = location) => getCleanPathname(url) === "notifications";
85
306
  const isOrganizationProfile = () => exists('meta[name="hovercard-subject-tag"][content^="organization"]');
86
-
87
- const isOrganizationRepo = () => {
88
- var _a;
89
- return Boolean(null === (_a = document.querySelector("[data-owner-scoped-search-url]")) || void 0 === _a ? void 0 : _a.dataset.ownerScopedSearchUrl.startsWith("/org"));
90
- };
91
-
92
- const isOrganizationDiscussion = (url = location) => /^orgs\/[^/]+\/teams\/[^/]+($|\/discussions)/.test(getCleanPathname(url));
93
-
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));
94
309
  const isOwnUserProfile = () => getCleanPathname() === getUsername();
95
-
96
310
  const isOwnOrganizationProfile = () => isOrganizationProfile() && !exists('[href*="contact/report-abuse?report="]');
97
-
98
- const isProject = (url = location) => {
99
- var _a;
100
- return /^projects\/\d+/.test(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
101
- };
102
-
103
- const isProjects = (url = location) => {
104
- var _a;
105
- return "projects" === (null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
106
- };
107
-
108
- const isDiscussion = (url = location) => {
109
- var _a;
110
- return /^discussions\/\d+/.test(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
111
- };
112
-
113
- const isDiscussionList = (url = location) => {
114
- var _a;
115
- return "discussions" === (null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
116
- };
117
-
118
- const isPR = (url = location) => {
119
- var _a;
120
- return /^pull\/\d+/.test(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path) && !isPRConflicts(url);
121
- };
122
-
123
- const isPRConflicts = (url = location) => {
124
- var _a;
125
- return /^pull\/\d+\/conflicts/.test(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
126
- };
127
-
128
- const isPRList = (url = location) => {
129
- var _a;
130
- return "/pulls" === url.pathname || "pulls" === (null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
131
- };
132
-
133
- const isPRCommit = (url = location) => {
134
- var _a;
135
- return /^pull\/\d+\/commits\/[\da-f]{5,40}$/.test(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
136
- };
137
-
138
- const isPRCommit404 = () => isPRCommit() && document.title.startsWith("Commit range not found · Pull Request");
139
-
140
- const isPRFile404 = () => isPRFiles() && document.title.startsWith("Commit range not found · Pull Request");
141
-
142
- const isPRConversation = (url = location) => {
143
- var _a;
144
- return /^pull\/\d+$/.test(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
145
- };
146
-
147
- const isPRCommitList = (url = location) => {
148
- var _a;
149
- return /^pull\/\d+\/commits$/.test(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
150
- };
151
-
152
- const isPRFiles = (url = location) => {
153
- var _a;
154
- return /^pull\/\d+\/files/.test(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
155
- };
156
-
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);
157
324
  const isQuickPR = (url = location) => isCompare(url) && /[?&]quick_pull=1(&|$)/.test(url.search);
158
-
159
- const isDraftPR = () => exists('#partial-discussion-header [title="Status: Draft"]');
160
-
161
- const isOpenPR = () => exists('#partial-discussion-header [title="Status: Open"], #partial-discussion-header [title="Status: Draft"]');
162
-
163
- const isMergedPR = () => exists('#partial-discussion-header [title="Status: Merged"]');
164
-
165
- const isClosedConversation = () => exists('#partial-discussion-header :is([title="Status: Closed"], [title="Status: Merged"], [title="Status: Closed as not planned"])');
166
-
167
- const isClosedPR = isClosedConversation;
168
-
169
- const isReleases = (url = location) => {
170
- var _a;
171
- return "releases" === (null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
172
- };
173
-
174
- const isTags = (url = location) => {
175
- var _a;
176
- return "tags" === (null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
177
- };
178
-
179
- const isSingleTag = (url = location) => {
180
- var _a;
181
- return /^(releases\/tag)/.test(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
182
- };
183
-
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);
184
333
  const isReleasesOrTags = (url = location) => isReleases(url) || isTags(url) || isSingleTag(url);
185
-
186
- const isDeletingFile = (url = location) => {
187
- var _a;
188
- return Boolean(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path.startsWith("delete"));
189
- };
190
-
191
- const isEditingFile = (url = location) => {
192
- var _a;
193
- return Boolean(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path.startsWith("edit"));
194
- };
195
-
334
+ const isDeletingFile = (url = location) => Boolean(getRepo(url)?.path.startsWith("delete"));
335
+ const isEditingFile = (url = location) => Boolean(getRepo(url)?.path.startsWith("edit"));
196
336
  const hasFileEditor = (url = location) => isEditingFile(url) || isNewFile(url) || isDeletingFile(url);
197
-
198
- const isEditingRelease = (url = location) => {
199
- var _a;
200
- return Boolean(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path.startsWith("releases/edit"));
201
- };
202
-
337
+ const isEditingRelease = (url = location) => Boolean(getRepo(url)?.path.startsWith("releases/edit"));
203
338
  const hasReleaseEditor = (url = location) => isEditingRelease(url) || isNewRelease(url);
204
-
205
339
  const isEditingWikiPage = (url = location) => isRepoWiki(url) && getCleanPathname(url).endsWith("/_edit");
206
-
207
340
  const hasWikiPageEditor = (url = location) => isEditingWikiPage(url) || isNewWikiPage(url);
208
-
209
- const isRepo = (url = location) => /^[^/]+\/[^/]+/.test(getCleanPathname(url)) && !reservedNames.includes(url.pathname.split("/", 2)[1]) && !isDashboard(url) && !isGist(url) && !isRepoSearch(url) && !isNewRepoTemplate(url);
210
-
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);
211
343
  const isEmptyRepoRoot = () => isRepoHome() && !exists('link[rel="canonical"]');
212
-
213
344
  const isEmptyRepo = () => exists('[aria-label="Cannot fork because repository is empty."]');
214
-
345
+ const isArchivedRepo = () => Boolean(isRepo() && $("#repository-container-header .Label").textContent.endsWith("archive"));
215
346
  const isBlank = () => exists("main .blankslate");
216
-
217
- const isRepoTaxonomyConversationList = (url = location) => {
218
- var _a;
219
- return /^labels\/.+|^milestones\/\d+(?!\/edit)/.test(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
220
- };
221
-
222
- const isRepoConversationList = (url = location) => isRepoPRList(url) || isRepoIssueList(url) || isRepoTaxonomyConversationList(url);
223
-
224
- const isRepoPRList = (url = location) => {
225
- var _a;
226
- return Boolean(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path.startsWith("pulls"));
227
- };
228
-
229
- const isRepoIssueList = (url = location) => {
230
- var _a;
231
- return /^labels\/|^issues(?!\/(\d+|new|templates)($|\/))/.test(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
232
- };
233
-
234
- const isRepoHome = (url = location) => {
235
- var _a;
236
- return "" === (null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
237
- };
238
-
239
- const isRepoRoot = url => {
240
- const repository = getRepo(null != url ? url : location);
241
- return !!repository && (!repository.path || (url ? /^tree\/[^/]+$/.test(repository.path) : repository.path.startsWith("tree/") && document.title.startsWith(repository.nameWithOwner) && !document.title.endsWith(repository.nameWithOwner)));
242
- };
243
-
244
- const isRepoSearch = (url = location) => "search" === url.pathname.split("/")[3];
245
-
246
- const isRepoSettings = (url = location) => {
247
- var _a;
248
- return Boolean(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path.startsWith("settings"));
249
- };
250
-
251
- const isRepoMainSettings = (url = location) => {
252
- var _a;
253
- return "settings" === (null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
254
- };
255
-
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";
256
368
  const isRepliesSettings = (url = location) => url.pathname.startsWith("/settings/replies");
257
-
258
369
  const isUserSettings = (url = location) => url.pathname.startsWith("/settings/");
259
-
260
- const isRepoTree = (url = location) => {
261
- var _a;
262
- return isRepoRoot(url) || Boolean(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path.startsWith("tree/"));
263
- };
264
-
265
- const isRepoWiki = (url = location) => {
266
- var _a;
267
- return Boolean(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path.startsWith("wiki"));
268
- };
269
-
270
- const isSingleCommit = (url = location) => {
271
- var _a;
272
- return /^commit\/[\da-f]{5,40}$/.test(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
273
- };
274
-
275
- const isSingleFile = (url = location) => {
276
- var _a;
277
- return Boolean(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path.startsWith("blob/"));
278
- };
279
-
280
- const isFileFinder = (url = location) => {
281
- var _a;
282
- return Boolean(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path.startsWith("find/"));
283
- };
284
-
285
- const isRepoForksList = (url = location) => {
286
- var _a;
287
- return "network/members" === (null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
288
- };
289
-
290
- const isRepoNetworkGraph = (url = location) => {
291
- var _a;
292
- return "network" === (null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
293
- };
294
-
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";
295
377
  const isForkedRepo = () => exists('meta[name="octolytics-dimension-repository_is_fork"][content="true"]');
296
-
297
- const isSingleGist = (url = location) => isGist(url) && /^\/(gist\/)?[^/]+\/[\da-f]{32}$/.test(url.pathname);
298
-
299
- const isGistRevision = (url = location) => isGist(url) && /^\/(gist\/)?[^/]+\/[\da-f]{32}\/revisions$/.test(url.pathname);
300
-
301
- const isTrending = (url = location) => "/trending" === url.pathname || url.pathname.startsWith("/trending/");
302
-
303
- const isBranches = (url = location) => {
304
- var _a;
305
- return Boolean(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path.startsWith("branches"));
306
- };
307
-
308
- const isProfile = (url = location) => {
309
- const pathname = getCleanPathname(url);
310
- return pathname.length > 0 && !pathname.includes("/") && !pathname.includes(".") && !reservedNames.includes(pathname);
311
- };
312
-
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));
313
385
  const isUserProfile = () => isProfile() && !isOrganizationProfile();
314
-
386
+ const isPrivateUserProfile = () => isUserProfile() && !exists(".user-following-container");
315
387
  const isUserProfileMainTab = () => isUserProfile() && !new URLSearchParams(location.search).has("tab");
316
-
317
- const isUserProfileRepoTab = (url = location) => isProfile(url) && "repositories" === new URLSearchParams(url.search).get("tab");
318
-
319
- const isUserProfileStarsTab = (url = location) => isProfile(url) && "stars" === new URLSearchParams(url.search).get("tab");
320
-
321
- const isUserProfileFollowersTab = (url = location) => isProfile(url) && "followers" === new URLSearchParams(url.search).get("tab");
322
-
323
- const isUserProfileFollowingTab = (url = location) => isProfile(url) && "following" === new URLSearchParams(url.search).get("tab");
324
-
325
- const hasComments = (url = location) => isPR(url) || isIssue(url) || isCommit(url) || isOrganizationDiscussion(url) || isSingleGist(url);
326
-
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);
327
393
  const hasRichTextEditor = (url = location) => hasComments(url) || isNewIssue(url) || isCompare(url) || isRepliesSettings(url) || hasReleaseEditor(url) || isDiscussion(url);
328
-
329
394
  const hasCode = (url = location) => hasComments(url) || isRepoTree(url) || isRepoSearch(url) || isGlobalSearchResults(url) || isSingleFile(url) || isGist(url) || isCompare(url) || isCompareWikiPage(url) || isBlame(url);
330
-
331
395
  const hasFiles = (url = location) => isCommit(url) || isCompare(url) || isPRFiles(url);
332
-
333
396
  const isMarketplaceAction = (url = location) => url.pathname.startsWith("/marketplace/actions/");
334
-
335
- const isActionJobRun = (url = location) => {
336
- var _a;
337
- return Boolean(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path.startsWith("runs/"));
338
- };
339
-
340
- const isActionRun = (url = location) => {
341
- var _a;
342
- return /^(actions\/)?runs/.test(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
343
- };
344
-
345
- const isNewAction = (url = location) => {
346
- var _a;
347
- return "actions/new" === (null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
348
- };
349
-
350
- const isRepositoryActions = (url = location) => {
351
- var _a;
352
- return /^actions(\/workflows\/.+\.ya?ml)?$/.test(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
353
- };
354
-
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);
355
401
  const isUserTheOrganizationOwner = () => isOrganizationProfile() && exists('[aria-label="Organization"] [data-tab-item="org-header-settings-tab"]');
356
-
357
- const canUserEditOrganization = isUserTheOrganizationOwner;
358
-
359
402
  const canUserEditRepo = () => isRepo() && exists('.reponav-item[href$="/settings"], [data-tab-item$="settings-tab"]');
360
-
361
- const isNewRepo = (url = location) => "/new" === url.pathname || /^organizations\/[^/]+\/repositories\/new$/.test(getCleanPathname(url));
362
-
363
- const isNewRepoTemplate = (url = location) => Boolean("generate" === url.pathname.split("/")[3]);
364
-
365
- const getUsername = () => {
366
- var _a;
367
- return null === (_a = document.querySelector('meta[name="user-login"]')) || void 0 === _a ? void 0 : _a.getAttribute("content");
368
- };
369
-
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");
370
406
  const getCleanPathname = (url = location) => url.pathname.replace(/\/+/g, "/").slice(1, url.pathname.endsWith("/") ? -1 : void 0);
371
-
372
- const getRepo = url => {
373
- if (!url) {
374
- const canonical = document.querySelector('[property="og:url"]');
375
- if (canonical) {
376
- const canonicalUrl = new URL(canonical.content, location.origin);
377
- getCleanPathname(canonicalUrl).toLowerCase() === getCleanPathname(location).toLowerCase() && (url = canonicalUrl);
378
- }
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
+ }
379
423
  }
380
- "string" == typeof url && (url = new URL(url, location.origin));
381
- if (!isRepo(url)) return;
382
- const [owner, name, ...path] = getCleanPathname(url).split("/");
383
- return {
384
- owner: owner,
385
- name: name,
386
- nameWithOwner: owner + "/" + name,
387
- path: path.join("/")
388
- };
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
+ };
389
438
  };
390
-
391
439
  const utils = {
392
- getUsername: getUsername,
393
- getCleanPathname: getCleanPathname,
394
- 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
395
558
  };
396
-
397
- export { canUserEditOrganization, canUserEditRepo, hasCode, hasComments, hasFileEditor, hasFiles, hasReleaseEditor, hasRichTextEditor, hasWikiPageEditor, is404, is500, isActionJobRun, isActionRun, 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, 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.12.1",
3
+ "version": "6.0.1",
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": "npm run 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
  ```