github-url-detection 5.8.0 → 5.11.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 +13 -5
- package/package.json +19 -25
- package/readme.md +4 -4
package/distribution/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export declare const isCommit: (url?: URL | HTMLAnchorElement | Location) => boo
|
|
|
6
6
|
export declare const isCommitList: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
7
7
|
export declare const isRepoCommitList: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
8
8
|
export declare const isCompare: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
9
|
+
export declare const isCompareWikiPage: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
9
10
|
export declare const isDashboard: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
10
11
|
export declare const isEnterprise: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
11
12
|
export declare const isGist: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
@@ -60,6 +61,7 @@ export declare const hasWikiPageEditor: (url?: URL | HTMLAnchorElement | Locatio
|
|
|
60
61
|
export declare const isRepo: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
61
62
|
export declare const isEmptyRepoRoot: () => boolean;
|
|
62
63
|
export declare const isEmptyRepo: () => boolean;
|
|
64
|
+
export declare const isBlank: () => boolean;
|
|
63
65
|
export declare const isRepoTaxonomyConversationList: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
64
66
|
export declare const isRepoConversationList: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
65
67
|
export declare const isRepoPRList: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
@@ -80,6 +82,7 @@ export declare const isRepoForksList: (url?: URL | HTMLAnchorElement | Location)
|
|
|
80
82
|
export declare const isRepoNetworkGraph: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
81
83
|
export declare const isForkedRepo: () => boolean;
|
|
82
84
|
export declare const isSingleGist: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
85
|
+
export declare const isGistRevision: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
83
86
|
export declare const isTrending: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
84
87
|
export declare const isBranches: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
85
88
|
export declare const isProfile: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
@@ -92,6 +95,7 @@ export declare const isUserProfileFollowingTab: (url?: URL | HTMLAnchorElement |
|
|
|
92
95
|
export declare const hasComments: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
93
96
|
export declare const hasRichTextEditor: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
94
97
|
export declare const hasCode: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
98
|
+
export declare const hasFiles: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
95
99
|
export declare const isMarketplaceAction: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
96
100
|
export declare const isActionJobRun: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
97
101
|
export declare const isActionRun: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
package/distribution/index.js
CHANGED
|
@@ -27,6 +27,8 @@ const isCompare = (url = location) => {
|
|
|
27
27
|
return Boolean(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path.startsWith("compare"));
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
+
const isCompareWikiPage = (url = location) => isRepoWiki(url) && getCleanPathname(url).split("/").slice(3, 5).includes("_compare");
|
|
31
|
+
|
|
30
32
|
const isDashboard = (url = location) => !isGist(url) && /^$|^(orgs\/[^/]+\/)?dashboard(\/|$)/.test(getCleanPathname(url));
|
|
31
33
|
|
|
32
34
|
const isEnterprise = (url = location) => "github.com" !== url.hostname && "gist.github.com" !== url.hostname;
|
|
@@ -130,7 +132,7 @@ const isPRList = (url = location) => {
|
|
|
130
132
|
|
|
131
133
|
const isPRCommit = (url = location) => {
|
|
132
134
|
var _a;
|
|
133
|
-
return /^pull\/\d+\/commits\/[\da-f]{5,40}
|
|
135
|
+
return /^pull\/\d+\/commits\/[\da-f]{5,40}$/.test(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
|
|
134
136
|
};
|
|
135
137
|
|
|
136
138
|
const isPRCommit404 = () => isPRCommit() && document.title.startsWith("Commit range not found · Pull Request");
|
|
@@ -208,6 +210,8 @@ const isEmptyRepoRoot = () => isRepoHome() && !exists('link[rel="canonical"]');
|
|
|
208
210
|
|
|
209
211
|
const isEmptyRepo = () => exists('[aria-label="Cannot fork because repository is empty."]');
|
|
210
212
|
|
|
213
|
+
const isBlank = () => exists("main .blankslate");
|
|
214
|
+
|
|
211
215
|
const isRepoTaxonomyConversationList = (url = location) => {
|
|
212
216
|
var _a;
|
|
213
217
|
return /^labels\/.+|^milestones\/\d+(?!\/edit)/.test(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
|
|
@@ -263,7 +267,7 @@ const isRepoWiki = (url = location) => {
|
|
|
263
267
|
|
|
264
268
|
const isSingleCommit = (url = location) => {
|
|
265
269
|
var _a;
|
|
266
|
-
return /^commit\/[\da-f]{5,40}
|
|
270
|
+
return /^commit\/[\da-f]{5,40}$/.test(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
|
|
267
271
|
};
|
|
268
272
|
|
|
269
273
|
const isSingleFile = (url = location) => {
|
|
@@ -290,6 +294,8 @@ const isForkedRepo = () => exists('meta[name="octolytics-dimension-repository_is
|
|
|
290
294
|
|
|
291
295
|
const isSingleGist = (url = location) => isGist(url) && /^\/(gist\/)?[^/]+\/[\da-f]{32}$/.test(url.pathname);
|
|
292
296
|
|
|
297
|
+
const isGistRevision = (url = location) => isGist(url) && /^\/(gist\/)?[^/]+\/[\da-f]{32}\/revisions$/.test(url.pathname);
|
|
298
|
+
|
|
293
299
|
const isTrending = (url = location) => "/trending" === url.pathname || url.pathname.startsWith("/trending/");
|
|
294
300
|
|
|
295
301
|
const isBranches = (url = location) => {
|
|
@@ -299,7 +305,7 @@ const isBranches = (url = location) => {
|
|
|
299
305
|
|
|
300
306
|
const isProfile = (url = location) => {
|
|
301
307
|
const pathname = getCleanPathname(url);
|
|
302
|
-
return pathname.length > 0 && !pathname.includes("/") && !reservedNames.includes(pathname);
|
|
308
|
+
return pathname.length > 0 && !pathname.includes("/") && !pathname.includes(".") && !reservedNames.includes(pathname);
|
|
303
309
|
};
|
|
304
310
|
|
|
305
311
|
const isUserProfile = () => isProfile() && !isOrganizationProfile();
|
|
@@ -318,7 +324,9 @@ const hasComments = (url = location) => isPR(url) || isIssue(url) || isCommit(ur
|
|
|
318
324
|
|
|
319
325
|
const hasRichTextEditor = (url = location) => hasComments(url) || isNewIssue(url) || isCompare(url) || isRepliesSettings(url) || hasReleaseEditor(url) || isDiscussion(url);
|
|
320
326
|
|
|
321
|
-
const hasCode = (url = location) => hasComments(url) || isRepoTree(url) || isSingleFile(url) || isGist(url) || isCompare(url) || isBlame(url);
|
|
327
|
+
const hasCode = (url = location) => hasComments(url) || isRepoTree(url) || isRepoSearch(url) || isGlobalSearchResults(url) || isSingleFile(url) || isGist(url) || isCompare(url) || isCompareWikiPage(url) || isBlame(url);
|
|
328
|
+
|
|
329
|
+
const hasFiles = (url = location) => isCommit(url) || isCompare(url) || isPRFiles(url);
|
|
322
330
|
|
|
323
331
|
const isMarketplaceAction = (url = location) => url.pathname.startsWith("/marketplace/actions/");
|
|
324
332
|
|
|
@@ -384,4 +392,4 @@ const utils = {
|
|
|
384
392
|
getRepositoryInfo: getRepo
|
|
385
393
|
};
|
|
386
394
|
|
|
387
|
-
export { canUserEditOrganization, canUserEditRepo, hasCode, hasComments, hasFileEditor, 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 };
|
|
395
|
+
export { canUserEditOrganization, canUserEditRepo, hasCode, hasComments, hasFileEditor, hasFiles, hasReleaseEditor, hasRichTextEditor, hasWikiPageEditor, is404, is500, isActionJobRun, isActionRun, isBlame, isBlank, isBranches, 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.
|
|
3
|
+
"version": "5.11.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",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"test",
|
|
11
11
|
"extension"
|
|
12
12
|
],
|
|
13
|
-
"repository": "
|
|
13
|
+
"repository": "refined-github/github-url-detection",
|
|
14
14
|
"funding": "https://github.com/sponsors/fregante",
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"author": "Federico Brigante <me@fregante.com> (https://fregante.com)",
|
|
@@ -22,6 +22,10 @@
|
|
|
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
|
+
},
|
|
25
29
|
"scripts": {
|
|
26
30
|
"ava": "ava --timeout 30s",
|
|
27
31
|
"build": "rollup -c",
|
|
@@ -55,28 +59,17 @@
|
|
|
55
59
|
"@typescript-eslint/no-non-null-assertion": "off",
|
|
56
60
|
"@typescript-eslint/no-unsafe-member-access": "off",
|
|
57
61
|
"@typescript-eslint/no-non-null-asserted-optional-chain": "off",
|
|
58
|
-
"@typescript-eslint/
|
|
59
|
-
"error",
|
|
60
|
-
"always-multiline"
|
|
61
|
-
]
|
|
62
|
+
"@typescript-eslint/naming-convention": "off"
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
65
|
],
|
|
65
66
|
"rules": {
|
|
66
|
-
"camelcase": "off"
|
|
67
|
-
"comma-dangle": [
|
|
68
|
-
"error",
|
|
69
|
-
"always-multiline"
|
|
70
|
-
],
|
|
71
|
-
"import/extensions": "off",
|
|
72
|
-
"import/no-useless-path-segments": "off",
|
|
73
|
-
"unicorn/import-index": "off"
|
|
67
|
+
"camelcase": "off"
|
|
74
68
|
}
|
|
75
69
|
},
|
|
76
70
|
"ava": {
|
|
77
71
|
"environmentVariables": {
|
|
78
|
-
"TS_NODE_FILES": "true"
|
|
79
|
-
"TS_NODE_COMPILER_OPTIONS": "{\"module\": \"esnext\", \"allowSyntheticDefaultImports\": true}"
|
|
72
|
+
"TS_NODE_FILES": "true"
|
|
80
73
|
},
|
|
81
74
|
"extensions": {
|
|
82
75
|
"ts": "module"
|
|
@@ -91,25 +84,26 @@
|
|
|
91
84
|
},
|
|
92
85
|
"devDependencies": {
|
|
93
86
|
"@rollup/plugin-json": "^4.1.0",
|
|
94
|
-
"@rollup/plugin-node-resolve": "^13.0.
|
|
95
|
-
"@rollup/plugin-typescript": "^8.
|
|
87
|
+
"@rollup/plugin-node-resolve": "^13.0.6",
|
|
88
|
+
"@rollup/plugin-typescript": "^8.3.0",
|
|
96
89
|
"@sindresorhus/tsconfig": "^2.0.0",
|
|
90
|
+
"@types/estree": "^0.0.50",
|
|
97
91
|
"@types/jsdom": "^16.2.13",
|
|
98
92
|
"ava": "^3.15.0",
|
|
99
93
|
"github-reserved-names": "^2.0.4",
|
|
100
|
-
"jsdom": "^
|
|
94
|
+
"jsdom": "^19.0.0",
|
|
101
95
|
"npm-run-all": "^4.1.5",
|
|
102
96
|
"parcel-bundler": "^1.12.4",
|
|
103
97
|
"parcel-plugin-svelte": "^4.0.9",
|
|
104
|
-
"rollup": "^2.
|
|
98
|
+
"rollup": "^2.60.2",
|
|
105
99
|
"rollup-plugin-terser": "^7.0.2",
|
|
106
100
|
"strip-indent": "^4.0.0",
|
|
107
|
-
"svelte": "^3.
|
|
108
|
-
"svelte-check": "^2.2.
|
|
109
|
-
"ts-node": "^10.
|
|
101
|
+
"svelte": "^3.44.2",
|
|
102
|
+
"svelte-check": "^2.2.10",
|
|
103
|
+
"ts-node": "^10.4.0",
|
|
110
104
|
"tslib": "^2.3.1",
|
|
111
|
-
"typescript": "^4.
|
|
112
|
-
"xo": "^0.
|
|
105
|
+
"typescript": "^4.5.2",
|
|
106
|
+
"xo": "^0.47.0"
|
|
113
107
|
},
|
|
114
108
|
"engines": {
|
|
115
109
|
"node": ">=12"
|
package/readme.md
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
Battle-tested by and extracted from the [Refined GitHub](https://github.com/sindresorhus/refined-github) extension.
|
|
6
6
|
|
|
7
|
-
- Try the live [demo](https://
|
|
8
|
-
- See the code and expected URLs for [every detection](https://github.com/
|
|
7
|
+
- Try the live [demo](https://refined-github.github.io/github-url-detection/)
|
|
8
|
+
- See the code and expected URLs for [every detection](https://github.com/refined-github/github-url-detection/blob/main/index.ts)
|
|
9
9
|
|
|
10
10
|
## Install
|
|
11
11
|
|
|
@@ -21,7 +21,7 @@ import * as pageDetect from 'github-url-detection';
|
|
|
21
21
|
## Usage
|
|
22
22
|
|
|
23
23
|
```js
|
|
24
|
-
const href = 'https://github.com/
|
|
24
|
+
const href = 'https://github.com/refined-github/github-url-detection/issues/1';
|
|
25
25
|
if (pageDetect.isIssue(new URL(href))) { // Pass the URL as an `URL` object
|
|
26
26
|
alert('The passed URL is of an issue!')
|
|
27
27
|
}
|
|
@@ -50,7 +50,7 @@ if (pageDetect.isConversationList()) {
|
|
|
50
50
|
```
|
|
51
51
|
|
|
52
52
|
```js
|
|
53
|
-
if (pageDetect.isConversationList(new URL('https://github.com/
|
|
53
|
+
if (pageDetect.isConversationList(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
|
```
|