github-url-detection 5.9.0 → 5.10.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 +2 -0
- package/distribution/index.js +6 -2
- package/package.json +2 -2
- package/readme.md +4 -4
package/distribution/index.d.ts
CHANGED
|
@@ -60,6 +60,7 @@ export declare const hasWikiPageEditor: (url?: URL | HTMLAnchorElement | Locatio
|
|
|
60
60
|
export declare const isRepo: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
61
61
|
export declare const isEmptyRepoRoot: () => boolean;
|
|
62
62
|
export declare const isEmptyRepo: () => boolean;
|
|
63
|
+
export declare const isBlank: () => boolean;
|
|
63
64
|
export declare const isRepoTaxonomyConversationList: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
64
65
|
export declare const isRepoConversationList: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
65
66
|
export declare const isRepoPRList: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
@@ -80,6 +81,7 @@ export declare const isRepoForksList: (url?: URL | HTMLAnchorElement | Location)
|
|
|
80
81
|
export declare const isRepoNetworkGraph: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
81
82
|
export declare const isForkedRepo: () => boolean;
|
|
82
83
|
export declare const isSingleGist: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
84
|
+
export declare const isGistRevision: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
83
85
|
export declare const isTrending: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
84
86
|
export declare const isBranches: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
85
87
|
export declare const isProfile: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
package/distribution/index.js
CHANGED
|
@@ -208,6 +208,8 @@ const isEmptyRepoRoot = () => isRepoHome() && !exists('link[rel="canonical"]');
|
|
|
208
208
|
|
|
209
209
|
const isEmptyRepo = () => exists('[aria-label="Cannot fork because repository is empty."]');
|
|
210
210
|
|
|
211
|
+
const isBlank = () => exists("main .blankslate");
|
|
212
|
+
|
|
211
213
|
const isRepoTaxonomyConversationList = (url = location) => {
|
|
212
214
|
var _a;
|
|
213
215
|
return /^labels\/.+|^milestones\/\d+(?!\/edit)/.test(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
|
|
@@ -290,6 +292,8 @@ const isForkedRepo = () => exists('meta[name="octolytics-dimension-repository_is
|
|
|
290
292
|
|
|
291
293
|
const isSingleGist = (url = location) => isGist(url) && /^\/(gist\/)?[^/]+\/[\da-f]{32}$/.test(url.pathname);
|
|
292
294
|
|
|
295
|
+
const isGistRevision = (url = location) => isGist(url) && /^\/(gist\/)?[^/]+\/[\da-f]{32}\/revisions$/.test(url.pathname);
|
|
296
|
+
|
|
293
297
|
const isTrending = (url = location) => "/trending" === url.pathname || url.pathname.startsWith("/trending/");
|
|
294
298
|
|
|
295
299
|
const isBranches = (url = location) => {
|
|
@@ -318,7 +322,7 @@ const hasComments = (url = location) => isPR(url) || isIssue(url) || isCommit(ur
|
|
|
318
322
|
|
|
319
323
|
const hasRichTextEditor = (url = location) => hasComments(url) || isNewIssue(url) || isCompare(url) || isRepliesSettings(url) || hasReleaseEditor(url) || isDiscussion(url);
|
|
320
324
|
|
|
321
|
-
const hasCode = (url = location) => hasComments(url) || isRepoTree(url) || isSingleFile(url) || isGist(url) || isCompare(url) || isBlame(url);
|
|
325
|
+
const hasCode = (url = location) => hasComments(url) || isRepoTree(url) || isRepoSearch(url) || isGlobalSearchResults(url) || isSingleFile(url) || isGist(url) || isCompare(url) || isBlame(url);
|
|
322
326
|
|
|
323
327
|
const hasFiles = (url = location) => isCommit(url) || isCompare(url) || isPRFiles(url);
|
|
324
328
|
|
|
@@ -386,4 +390,4 @@ const utils = {
|
|
|
386
390
|
getRepositoryInfo: getRepo
|
|
387
391
|
};
|
|
388
392
|
|
|
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 };
|
|
393
|
+
export { canUserEditOrganization, canUserEditRepo, hasCode, hasComments, hasFileEditor, hasFiles, hasReleaseEditor, hasRichTextEditor, hasWikiPageEditor, is404, is500, isActionJobRun, isActionRun, isBlame, isBlank, isBranches, isClosedPR, isCommit, isCommitList, isCompare, 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.10.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)",
|
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
|
```
|