github-url-detection 5.7.0 → 5.9.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.
- package/distribution/index.d.ts +4 -0
- package/distribution/index.js +15 -7
- package/package.json +19 -24
package/distribution/index.d.ts
CHANGED
|
@@ -52,8 +52,11 @@ export declare const isSingleTag: (url?: URL | HTMLAnchorElement | Location) =>
|
|
|
52
52
|
export declare const isReleasesOrTags: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
53
53
|
export declare const isDeletingFile: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
54
54
|
export declare const isEditingFile: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
55
|
+
export declare const hasFileEditor: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
55
56
|
export declare const isEditingRelease: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
57
|
+
export declare const hasReleaseEditor: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
56
58
|
export declare const isEditingWikiPage: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
59
|
+
export declare const hasWikiPageEditor: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
57
60
|
export declare const isRepo: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
58
61
|
export declare const isEmptyRepoRoot: () => boolean;
|
|
59
62
|
export declare const isEmptyRepo: () => boolean;
|
|
@@ -89,6 +92,7 @@ export declare const isUserProfileFollowingTab: (url?: URL | HTMLAnchorElement |
|
|
|
89
92
|
export declare const hasComments: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
90
93
|
export declare const hasRichTextEditor: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
91
94
|
export declare const hasCode: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
95
|
+
export declare const hasFiles: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
92
96
|
export declare const isMarketplaceAction: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
93
97
|
export declare const isActionJobRun: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
94
98
|
export declare const isActionRun: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
package/distribution/index.js
CHANGED
|
@@ -2,7 +2,7 @@ var reservedNames = [ "400", "401", "402", "403", "404", "405", "406", "407", "4
|
|
|
2
2
|
|
|
3
3
|
const exists = selector => Boolean(document.querySelector(selector));
|
|
4
4
|
|
|
5
|
-
const is404 = () => "Page not found · GitHub"
|
|
5
|
+
const is404 = () => document.title.startsWith("Page not found · GitHub");
|
|
6
6
|
|
|
7
7
|
const is500 = () => "Server Error · GitHub" === document.title || "Unicorn! · GitHub" === document.title || "504 Gateway Time-out" === document.title;
|
|
8
8
|
|
|
@@ -130,7 +130,7 @@ const isPRList = (url = location) => {
|
|
|
130
130
|
|
|
131
131
|
const isPRCommit = (url = location) => {
|
|
132
132
|
var _a;
|
|
133
|
-
return /^pull\/\d+\/commits\/[\da-f]{5,40}
|
|
133
|
+
return /^pull\/\d+\/commits\/[\da-f]{5,40}$/.test(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
|
|
134
134
|
};
|
|
135
135
|
|
|
136
136
|
const isPRCommit404 = () => isPRCommit() && document.title.startsWith("Commit range not found · Pull Request");
|
|
@@ -189,13 +189,19 @@ const isEditingFile = (url = location) => {
|
|
|
189
189
|
return Boolean(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path.startsWith("edit"));
|
|
190
190
|
};
|
|
191
191
|
|
|
192
|
+
const hasFileEditor = (url = location) => isEditingFile(url) || isNewFile(url) || isDeletingFile(url);
|
|
193
|
+
|
|
192
194
|
const isEditingRelease = (url = location) => {
|
|
193
195
|
var _a;
|
|
194
196
|
return Boolean(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path.startsWith("releases/edit"));
|
|
195
197
|
};
|
|
196
198
|
|
|
199
|
+
const hasReleaseEditor = (url = location) => isEditingRelease(url) || isNewRelease(url);
|
|
200
|
+
|
|
197
201
|
const isEditingWikiPage = (url = location) => isRepoWiki(url) && getCleanPathname(url).endsWith("/_edit");
|
|
198
202
|
|
|
203
|
+
const hasWikiPageEditor = (url = location) => isEditingWikiPage(url) || isNewWikiPage(url);
|
|
204
|
+
|
|
199
205
|
const isRepo = (url = location) => /^[^/]+\/[^/]+/.test(getCleanPathname(url)) && !reservedNames.includes(url.pathname.split("/", 2)[1]) && !isDashboard(url) && !isGist(url) && !isRepoSearch(url) && !isNewRepoTemplate(url);
|
|
200
206
|
|
|
201
207
|
const isEmptyRepoRoot = () => isRepoHome() && !exists('link[rel="canonical"]');
|
|
@@ -257,7 +263,7 @@ const isRepoWiki = (url = location) => {
|
|
|
257
263
|
|
|
258
264
|
const isSingleCommit = (url = location) => {
|
|
259
265
|
var _a;
|
|
260
|
-
return /^commit\/[\da-f]{5,40}
|
|
266
|
+
return /^commit\/[\da-f]{5,40}$/.test(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
|
|
261
267
|
};
|
|
262
268
|
|
|
263
269
|
const isSingleFile = (url = location) => {
|
|
@@ -293,7 +299,7 @@ const isBranches = (url = location) => {
|
|
|
293
299
|
|
|
294
300
|
const isProfile = (url = location) => {
|
|
295
301
|
const pathname = getCleanPathname(url);
|
|
296
|
-
return pathname.length > 0 && !pathname.includes("/") && !reservedNames.includes(pathname);
|
|
302
|
+
return pathname.length > 0 && !pathname.includes("/") && !pathname.includes(".") && !reservedNames.includes(pathname);
|
|
297
303
|
};
|
|
298
304
|
|
|
299
305
|
const isUserProfile = () => isProfile() && !isOrganizationProfile();
|
|
@@ -310,10 +316,12 @@ const isUserProfileFollowingTab = (url = location) => isProfile(url) && "followi
|
|
|
310
316
|
|
|
311
317
|
const hasComments = (url = location) => isPR(url) || isIssue(url) || isCommit(url) || isOrganizationDiscussion(url) || isSingleGist(url);
|
|
312
318
|
|
|
313
|
-
const hasRichTextEditor = (url = location) => hasComments(url) || isNewIssue(url) || isCompare(url) || isRepliesSettings(url) ||
|
|
319
|
+
const hasRichTextEditor = (url = location) => hasComments(url) || isNewIssue(url) || isCompare(url) || isRepliesSettings(url) || hasReleaseEditor(url) || isDiscussion(url);
|
|
314
320
|
|
|
315
321
|
const hasCode = (url = location) => hasComments(url) || isRepoTree(url) || isSingleFile(url) || isGist(url) || isCompare(url) || isBlame(url);
|
|
316
322
|
|
|
323
|
+
const hasFiles = (url = location) => isCommit(url) || isCompare(url) || isPRFiles(url);
|
|
324
|
+
|
|
317
325
|
const isMarketplaceAction = (url = location) => url.pathname.startsWith("/marketplace/actions/");
|
|
318
326
|
|
|
319
327
|
const isActionJobRun = (url = location) => {
|
|
@@ -351,7 +359,7 @@ const getUsername = () => {
|
|
|
351
359
|
return null === (_a = document.querySelector('meta[name="user-login"]')) || void 0 === _a ? void 0 : _a.getAttribute("content");
|
|
352
360
|
};
|
|
353
361
|
|
|
354
|
-
const getCleanPathname = (url = location) => url.pathname.slice(1, url.pathname.endsWith("/") ? -1 : void 0);
|
|
362
|
+
const getCleanPathname = (url = location) => url.pathname.replace(/\/+/g, "/").slice(1, url.pathname.endsWith("/") ? -1 : void 0);
|
|
355
363
|
|
|
356
364
|
const getRepo = url => {
|
|
357
365
|
if (!url) {
|
|
@@ -378,4 +386,4 @@ const utils = {
|
|
|
378
386
|
getRepositoryInfo: getRepo
|
|
379
387
|
};
|
|
380
388
|
|
|
381
|
-
export { canUserEditOrganization, canUserEditRepo, hasCode, hasComments, hasRichTextEditor, is404, is500, isActionJobRun, isActionRun, isBlame, isBranches, isClosedPR, isCommit, isCommitList, isCompare, isConversation, isConversationList, isDashboard, isDeletingFile, isDiscussion, isDiscussionList, isDraftPR, isEditingFile, isEditingRelease, isEditingWikiPage, isEmptyRepo, isEmptyRepoRoot, isEnterprise, isFileFinder, isForkedRepo, isGist, 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 };
|
|
389
|
+
export { canUserEditOrganization, canUserEditRepo, hasCode, hasComments, hasFileEditor, hasFiles, hasReleaseEditor, hasRichTextEditor, hasWikiPageEditor, is404, is500, isActionJobRun, isActionRun, isBlame, isBranches, isClosedPR, isCommit, isCommitList, isCompare, isConversation, isConversationList, isDashboard, isDeletingFile, isDiscussion, isDiscussionList, isDraftPR, isEditingFile, isEditingRelease, isEditingWikiPage, isEmptyRepo, isEmptyRepoRoot, isEnterprise, isFileFinder, isForkedRepo, isGist, 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.
|
|
3
|
+
"version": "5.9.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",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"extension"
|
|
12
12
|
],
|
|
13
13
|
"repository": "fregante/github-url-detection",
|
|
14
|
+
"funding": "https://github.com/sponsors/fregante",
|
|
14
15
|
"license": "MIT",
|
|
15
16
|
"author": "Federico Brigante <me@fregante.com> (https://fregante.com)",
|
|
16
17
|
"sideEffects": false,
|
|
@@ -21,6 +22,10 @@
|
|
|
21
22
|
"distribution/index.js",
|
|
22
23
|
"distribution/index.d.ts"
|
|
23
24
|
],
|
|
25
|
+
"alias": {
|
|
26
|
+
"./this-stuff-is-just-for-local-parcel-tests": "./package.json",
|
|
27
|
+
"./collector.js": "./collector.ts"
|
|
28
|
+
},
|
|
24
29
|
"scripts": {
|
|
25
30
|
"ava": "ava --timeout 30s",
|
|
26
31
|
"build": "rollup -c",
|
|
@@ -54,28 +59,17 @@
|
|
|
54
59
|
"@typescript-eslint/no-non-null-assertion": "off",
|
|
55
60
|
"@typescript-eslint/no-unsafe-member-access": "off",
|
|
56
61
|
"@typescript-eslint/no-non-null-asserted-optional-chain": "off",
|
|
57
|
-
"@typescript-eslint/
|
|
58
|
-
"error",
|
|
59
|
-
"always-multiline"
|
|
60
|
-
]
|
|
62
|
+
"@typescript-eslint/naming-convention": "off"
|
|
61
63
|
}
|
|
62
64
|
}
|
|
63
65
|
],
|
|
64
66
|
"rules": {
|
|
65
|
-
"camelcase": "off"
|
|
66
|
-
"comma-dangle": [
|
|
67
|
-
"error",
|
|
68
|
-
"always-multiline"
|
|
69
|
-
],
|
|
70
|
-
"import/extensions": "off",
|
|
71
|
-
"import/no-useless-path-segments": "off",
|
|
72
|
-
"unicorn/import-index": "off"
|
|
67
|
+
"camelcase": "off"
|
|
73
68
|
}
|
|
74
69
|
},
|
|
75
70
|
"ava": {
|
|
76
71
|
"environmentVariables": {
|
|
77
|
-
"TS_NODE_FILES": "true"
|
|
78
|
-
"TS_NODE_COMPILER_OPTIONS": "{\"module\": \"esnext\", \"allowSyntheticDefaultImports\": true}"
|
|
72
|
+
"TS_NODE_FILES": "true"
|
|
79
73
|
},
|
|
80
74
|
"extensions": {
|
|
81
75
|
"ts": "module"
|
|
@@ -90,25 +84,26 @@
|
|
|
90
84
|
},
|
|
91
85
|
"devDependencies": {
|
|
92
86
|
"@rollup/plugin-json": "^4.1.0",
|
|
93
|
-
"@rollup/plugin-node-resolve": "^13.0.
|
|
94
|
-
"@rollup/plugin-typescript": "^8.
|
|
87
|
+
"@rollup/plugin-node-resolve": "^13.0.6",
|
|
88
|
+
"@rollup/plugin-typescript": "^8.3.0",
|
|
95
89
|
"@sindresorhus/tsconfig": "^2.0.0",
|
|
90
|
+
"@types/estree": "^0.0.50",
|
|
96
91
|
"@types/jsdom": "^16.2.13",
|
|
97
92
|
"ava": "^3.15.0",
|
|
98
93
|
"github-reserved-names": "^2.0.4",
|
|
99
|
-
"jsdom": "^
|
|
94
|
+
"jsdom": "^19.0.0",
|
|
100
95
|
"npm-run-all": "^4.1.5",
|
|
101
96
|
"parcel-bundler": "^1.12.4",
|
|
102
97
|
"parcel-plugin-svelte": "^4.0.9",
|
|
103
|
-
"rollup": "^2.
|
|
98
|
+
"rollup": "^2.60.2",
|
|
104
99
|
"rollup-plugin-terser": "^7.0.2",
|
|
105
100
|
"strip-indent": "^4.0.0",
|
|
106
|
-
"svelte": "^3.
|
|
107
|
-
"svelte-check": "^2.2.
|
|
108
|
-
"ts-node": "^10.
|
|
101
|
+
"svelte": "^3.44.2",
|
|
102
|
+
"svelte-check": "^2.2.10",
|
|
103
|
+
"ts-node": "^10.4.0",
|
|
109
104
|
"tslib": "^2.3.1",
|
|
110
|
-
"typescript": "^4.
|
|
111
|
-
"xo": "^0.
|
|
105
|
+
"typescript": "^4.5.2",
|
|
106
|
+
"xo": "^0.47.0"
|
|
112
107
|
},
|
|
113
108
|
"engines": {
|
|
114
109
|
"node": ">=12"
|