github-url-detection 5.4.0-0 → 5.4.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 +5 -12
- package/distribution/index.js +14 -23
- package/package.json +16 -15
- package/readme.md +0 -3
package/distribution/index.d.ts
CHANGED
|
@@ -23,15 +23,7 @@ export declare const isNewRelease: (url?: URL | HTMLAnchorElement | Location) =>
|
|
|
23
23
|
export declare const isNewWikiPage: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
24
24
|
export declare const isNotifications: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
25
25
|
export declare const isOrganizationProfile: () => boolean;
|
|
26
|
-
export declare const isOrganizationRepoList: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
27
26
|
export declare const isOrganizationRepo: () => boolean;
|
|
28
|
-
export declare const isOrganizationPackagesList: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
29
|
-
export declare const isOrganizationPeopleList: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
30
|
-
export declare const isOrganizationProjectsList: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
31
|
-
export declare const isOrganizationProject: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
32
|
-
export declare const isOrganizationDiscussionsList: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
33
|
-
export declare const isOrganizationTeamDiscussion: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
34
|
-
/** @deprecated use isOrganizationTeamDiscussion instead */
|
|
35
27
|
export declare const isOrganizationDiscussion: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
36
28
|
export declare const isOwnUserProfile: () => boolean;
|
|
37
29
|
export declare const isOwnOrganizationProfile: () => boolean;
|
|
@@ -82,12 +74,13 @@ export declare const isForkedRepo: () => boolean;
|
|
|
82
74
|
export declare const isSingleGist: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
83
75
|
export declare const isTrending: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
84
76
|
export declare const isBranches: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
77
|
+
export declare const isProfile: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
85
78
|
export declare const isUserProfile: () => boolean;
|
|
86
79
|
export declare const isUserProfileMainTab: () => boolean;
|
|
87
|
-
export declare const isUserProfileRepoTab: () => boolean;
|
|
88
|
-
export declare const isUserProfileStarsTab: () => boolean;
|
|
89
|
-
export declare const isUserProfileFollowersTab: () => boolean;
|
|
90
|
-
export declare const isUserProfileFollowingTab: () => boolean;
|
|
80
|
+
export declare const isUserProfileRepoTab: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
81
|
+
export declare const isUserProfileStarsTab: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
82
|
+
export declare const isUserProfileFollowersTab: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
83
|
+
export declare const isUserProfileFollowingTab: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
91
84
|
export declare const isSingleTag: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
92
85
|
export declare const hasComments: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
93
86
|
export declare const hasRichTextEditor: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
package/distribution/index.js
CHANGED
|
@@ -82,26 +82,12 @@ const isNotifications = (url = location) => "notifications" === getCleanPathname
|
|
|
82
82
|
|
|
83
83
|
const isOrganizationProfile = () => exists('meta[name="hovercard-subject-tag"][content^="organization"]');
|
|
84
84
|
|
|
85
|
-
const isOrganizationRepoList = (url = location) => /^orgs\/[^/]+\/repositories$/.test(getCleanPathname(url));
|
|
86
|
-
|
|
87
85
|
const isOrganizationRepo = () => {
|
|
88
86
|
var _a;
|
|
89
87
|
return Boolean(null === (_a = document.querySelector("[data-owner-scoped-search-url]")) || void 0 === _a ? void 0 : _a.dataset.ownerScopedSearchUrl.startsWith("/org"));
|
|
90
88
|
};
|
|
91
89
|
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
const isOrganizationPeopleList = (url = location) => /^orgs\/[^/]+\/people$/.test(getCleanPathname(url));
|
|
95
|
-
|
|
96
|
-
const isOrganizationProjectsList = (url = location) => /^orgs\/[^/]+\/projects$/.test(getCleanPathname(url));
|
|
97
|
-
|
|
98
|
-
const isOrganizationProject = (url = location) => /^orgs\/[^/]+\/projects\/[^/]+$/.test(getCleanPathname(url));
|
|
99
|
-
|
|
100
|
-
const isOrganizationDiscussionsList = (url = location) => /^orgs\/[^/]+\/discussions$/.test(getCleanPathname(url));
|
|
101
|
-
|
|
102
|
-
const isOrganizationTeamDiscussion = (url = location) => /^orgs\/[^/]+\/teams\/[^/]+($|\/discussions)/.test(getCleanPathname(url));
|
|
103
|
-
|
|
104
|
-
const isOrganizationDiscussion = isOrganizationTeamDiscussion;
|
|
90
|
+
const isOrganizationDiscussion = (url = location) => /^orgs\/[^/]+\/teams\/[^/]+($|\/discussions)/.test(getCleanPathname(url));
|
|
105
91
|
|
|
106
92
|
const isOwnUserProfile = () => getCleanPathname() === getUsername();
|
|
107
93
|
|
|
@@ -283,17 +269,22 @@ const isBranches = (url = location) => {
|
|
|
283
269
|
return Boolean(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path.startsWith("branches"));
|
|
284
270
|
};
|
|
285
271
|
|
|
286
|
-
const
|
|
272
|
+
const isProfile = (url = location) => {
|
|
273
|
+
const pathname = getCleanPathname(url);
|
|
274
|
+
return pathname.length > 0 && !pathname.includes("/") && !reservedNames.includes(pathname);
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
const isUserProfile = () => isProfile() && !isOrganizationProfile();
|
|
287
278
|
|
|
288
|
-
const isUserProfileMainTab = () =>
|
|
279
|
+
const isUserProfileMainTab = () => isUserProfile() && !new URLSearchParams(location.search).has("tab");
|
|
289
280
|
|
|
290
|
-
const isUserProfileRepoTab = () =>
|
|
281
|
+
const isUserProfileRepoTab = (url = location) => isProfile(url) && "repositories" === new URLSearchParams(url.search).get("tab");
|
|
291
282
|
|
|
292
|
-
const isUserProfileStarsTab = () =>
|
|
283
|
+
const isUserProfileStarsTab = (url = location) => isProfile(url) && "stars" === new URLSearchParams(url.search).get("tab");
|
|
293
284
|
|
|
294
|
-
const isUserProfileFollowersTab = () =>
|
|
285
|
+
const isUserProfileFollowersTab = (url = location) => isProfile(url) && "followers" === new URLSearchParams(url.search).get("tab");
|
|
295
286
|
|
|
296
|
-
const isUserProfileFollowingTab = () =>
|
|
287
|
+
const isUserProfileFollowingTab = (url = location) => isProfile(url) && "following" === new URLSearchParams(url.search).get("tab");
|
|
297
288
|
|
|
298
289
|
const isSingleTag = (url = location) => {
|
|
299
290
|
var _a;
|
|
@@ -302,7 +293,7 @@ const isSingleTag = (url = location) => {
|
|
|
302
293
|
|
|
303
294
|
const hasComments = (url = location) => isPR(url) || isIssue(url) || isCommit(url) || isOrganizationDiscussion(url) || isSingleGist(url);
|
|
304
295
|
|
|
305
|
-
const hasRichTextEditor = (url = location) => hasComments(url) || isNewIssue(url) || isCompare(url) || isRepliesSettings(url) || isDiscussion(url);
|
|
296
|
+
const hasRichTextEditor = (url = location) => hasComments(url) || isNewIssue(url) || isCompare(url) || isRepliesSettings(url) || isNewRelease(url) || isDiscussion(url);
|
|
306
297
|
|
|
307
298
|
const hasCode = (url = location) => hasComments(url) || isRepoTree(url) || isSingleFile(url) || isGist(url) || isCompare(url) || isBlame(url);
|
|
308
299
|
|
|
@@ -370,4 +361,4 @@ const utils = {
|
|
|
370
361
|
getRepositoryInfo: getRepo
|
|
371
362
|
};
|
|
372
363
|
|
|
373
|
-
export { canUserEditOrganization, canUserEditRepo, hasCode, hasComments, hasRichTextEditor, is404, is500, isActionJobRun, isActionRun, isBlame, isBranches, isClosedPR, isCommit, isCommitList, isCompare, isConversation, isConversationList, isDashboard, 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,
|
|
364
|
+
export { canUserEditOrganization, canUserEditRepo, hasCode, hasComments, hasRichTextEditor, is404, is500, isActionJobRun, isActionRun, isBlame, isBranches, isClosedPR, isCommit, isCommitList, isCompare, isConversation, isConversationList, isDashboard, 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, isQuickPR, isReleasesOrTags, isRepliesSettings, isRepo, isRepoCommitList, isRepoConversationList, isRepoForksList, isRepoHome, isRepoIssueList, isRepoMainSettings, isRepoNetworkGraph, isRepoPRList, isRepoRoot, isRepoSearch, isRepoSettings, isRepoTaxonomyConversationList, isRepoTree, isRepoWiki, isRepositoryActions, isSingleCommit, isSingleFile, isSingleGist, isSingleTag, 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.4.0
|
|
3
|
+
"version": "5.4.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",
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
"ava/assertion-arguments": "off",
|
|
53
53
|
"@typescript-eslint/dot-notation": "off",
|
|
54
54
|
"@typescript-eslint/no-non-null-assertion": "off",
|
|
55
|
+
"@typescript-eslint/no-unsafe-member-access": "off",
|
|
55
56
|
"@typescript-eslint/no-non-null-asserted-optional-chain": "off",
|
|
56
57
|
"@typescript-eslint/comma-dangle": [
|
|
57
58
|
"error",
|
|
@@ -89,25 +90,25 @@
|
|
|
89
90
|
},
|
|
90
91
|
"devDependencies": {
|
|
91
92
|
"@rollup/plugin-json": "^4.1.0",
|
|
92
|
-
"@rollup/plugin-node-resolve": "^
|
|
93
|
-
"@rollup/plugin-typescript": "^8.2.
|
|
94
|
-
"@sindresorhus/tsconfig": "^
|
|
95
|
-
"@types/jsdom": "^16.2.
|
|
93
|
+
"@rollup/plugin-node-resolve": "^13.0.5",
|
|
94
|
+
"@rollup/plugin-typescript": "^8.2.5",
|
|
95
|
+
"@sindresorhus/tsconfig": "^2.0.0",
|
|
96
|
+
"@types/jsdom": "^16.2.13",
|
|
96
97
|
"ava": "^3.15.0",
|
|
97
98
|
"github-reserved-names": "^2.0.4",
|
|
98
|
-
"jsdom": "^
|
|
99
|
+
"jsdom": "^17.0.0",
|
|
99
100
|
"npm-run-all": "^4.1.5",
|
|
100
101
|
"parcel-bundler": "^1.12.4",
|
|
101
|
-
"parcel-plugin-svelte": "^4.0.
|
|
102
|
-
"rollup": "^2.
|
|
102
|
+
"parcel-plugin-svelte": "^4.0.9",
|
|
103
|
+
"rollup": "^2.57.0",
|
|
103
104
|
"rollup-plugin-terser": "^7.0.2",
|
|
104
|
-
"strip-indent": "^
|
|
105
|
-
"svelte": "^3.
|
|
106
|
-
"svelte-check": "^
|
|
107
|
-
"ts-node": "^
|
|
108
|
-
"tslib": "^2.
|
|
109
|
-
"typescript": "^4.
|
|
110
|
-
"xo": "^0.
|
|
105
|
+
"strip-indent": "^4.0.0",
|
|
106
|
+
"svelte": "^3.43.0",
|
|
107
|
+
"svelte-check": "^2.2.6",
|
|
108
|
+
"ts-node": "^10.2.1",
|
|
109
|
+
"tslib": "^2.3.1",
|
|
110
|
+
"typescript": "^4.4.3",
|
|
111
|
+
"xo": "^0.44.0"
|
|
111
112
|
},
|
|
112
113
|
"engines": {
|
|
113
114
|
"node": ">=12"
|
package/readme.md
CHANGED
|
@@ -37,8 +37,6 @@ if (pageDetect.isConversationList()) {
|
|
|
37
37
|
|
|
38
38
|
## API
|
|
39
39
|
|
|
40
|
-
In the source you can see the [full list of detections](https://www.unpkg.com/browse/github-url-detection@latest/esm/index.d.ts) and [their matching URLs.](https://github.com/fregante/github-url-detection/blob/master/index.ts)
|
|
41
|
-
|
|
42
40
|
Most detections are URL-based while others need access to the current `document`. You can determine which ones are URL-based by looking at their signature: URL-based functions have a `url` parameter.
|
|
43
41
|
|
|
44
42
|
### URL-based detections
|
|
@@ -63,7 +61,6 @@ Notice that the `url` parameter is not a plain string but it has to be a proper
|
|
|
63
61
|
|
|
64
62
|
By default, `document`-based detections use the `document` global, which means they can only be used if you have the whole page, you can't just test any random URL string.
|
|
65
63
|
|
|
66
|
-
|
|
67
64
|
```js
|
|
68
65
|
if (pageDetect.isOrganizationProfile()) {
|
|
69
66
|
alert('You’re on an organization profile, like https://github.com/babel')
|