github-url-detection 5.9.0 → 5.12.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.
@@ -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;
@@ -45,6 +46,8 @@ export declare const isQuickPR: (url?: URL | HTMLAnchorElement | Location) => bo
45
46
  export declare const isDraftPR: () => boolean;
46
47
  export declare const isOpenPR: () => boolean;
47
48
  export declare const isMergedPR: () => boolean;
49
+ export declare const isClosedConversation: () => boolean;
50
+ /** @deprecated Use isClosedConversation */
48
51
  export declare const isClosedPR: () => boolean;
49
52
  export declare const isReleases: (url?: URL | HTMLAnchorElement | Location) => boolean;
50
53
  export declare const isTags: (url?: URL | HTMLAnchorElement | Location) => boolean;
@@ -60,6 +63,7 @@ export declare const hasWikiPageEditor: (url?: URL | HTMLAnchorElement | Locatio
60
63
  export declare const isRepo: (url?: URL | HTMLAnchorElement | Location) => boolean;
61
64
  export declare const isEmptyRepoRoot: () => boolean;
62
65
  export declare const isEmptyRepo: () => boolean;
66
+ export declare const isBlank: () => boolean;
63
67
  export declare const isRepoTaxonomyConversationList: (url?: URL | HTMLAnchorElement | Location) => boolean;
64
68
  export declare const isRepoConversationList: (url?: URL | HTMLAnchorElement | Location) => boolean;
65
69
  export declare const isRepoPRList: (url?: URL | HTMLAnchorElement | Location) => boolean;
@@ -80,6 +84,7 @@ export declare const isRepoForksList: (url?: URL | HTMLAnchorElement | Location)
80
84
  export declare const isRepoNetworkGraph: (url?: URL | HTMLAnchorElement | Location) => boolean;
81
85
  export declare const isForkedRepo: () => boolean;
82
86
  export declare const isSingleGist: (url?: URL | HTMLAnchorElement | Location) => boolean;
87
+ export declare const isGistRevision: (url?: URL | HTMLAnchorElement | Location) => boolean;
83
88
  export declare const isTrending: (url?: URL | HTMLAnchorElement | Location) => boolean;
84
89
  export declare const isBranches: (url?: URL | HTMLAnchorElement | Location) => boolean;
85
90
  export declare const isProfile: (url?: URL | HTMLAnchorElement | Location) => boolean;
@@ -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;
@@ -160,7 +162,9 @@ const isOpenPR = () => exists('#partial-discussion-header [title="Status: Open"]
160
162
 
161
163
  const isMergedPR = () => exists('#partial-discussion-header [title="Status: Merged"]');
162
164
 
163
- const isClosedPR = () => exists('#partial-discussion-header [title="Status: Closed"], #partial-discussion-header [title="Status: Merged"]');
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;
164
168
 
165
169
  const isReleases = (url = location) => {
166
170
  var _a;
@@ -208,6 +212,8 @@ const isEmptyRepoRoot = () => isRepoHome() && !exists('link[rel="canonical"]');
208
212
 
209
213
  const isEmptyRepo = () => exists('[aria-label="Cannot fork because repository is empty."]');
210
214
 
215
+ const isBlank = () => exists("main .blankslate");
216
+
211
217
  const isRepoTaxonomyConversationList = (url = location) => {
212
218
  var _a;
213
219
  return /^labels\/.+|^milestones\/\d+(?!\/edit)/.test(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
@@ -290,6 +296,8 @@ const isForkedRepo = () => exists('meta[name="octolytics-dimension-repository_is
290
296
 
291
297
  const isSingleGist = (url = location) => isGist(url) && /^\/(gist\/)?[^/]+\/[\da-f]{32}$/.test(url.pathname);
292
298
 
299
+ const isGistRevision = (url = location) => isGist(url) && /^\/(gist\/)?[^/]+\/[\da-f]{32}\/revisions$/.test(url.pathname);
300
+
293
301
  const isTrending = (url = location) => "/trending" === url.pathname || url.pathname.startsWith("/trending/");
294
302
 
295
303
  const isBranches = (url = location) => {
@@ -318,7 +326,7 @@ const hasComments = (url = location) => isPR(url) || isIssue(url) || isCommit(ur
318
326
 
319
327
  const hasRichTextEditor = (url = location) => hasComments(url) || isNewIssue(url) || isCompare(url) || isRepliesSettings(url) || hasReleaseEditor(url) || isDiscussion(url);
320
328
 
321
- const hasCode = (url = location) => hasComments(url) || isRepoTree(url) || isSingleFile(url) || isGist(url) || isCompare(url) || isBlame(url);
329
+ const hasCode = (url = location) => hasComments(url) || isRepoTree(url) || isRepoSearch(url) || isGlobalSearchResults(url) || isSingleFile(url) || isGist(url) || isCompare(url) || isCompareWikiPage(url) || isBlame(url);
322
330
 
323
331
  const hasFiles = (url = location) => isCommit(url) || isCompare(url) || isPRFiles(url);
324
332
 
@@ -386,4 +394,4 @@ const utils = {
386
394
  getRepositoryInfo: getRepo
387
395
  };
388
396
 
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 };
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.9.0",
3
+ "version": "5.12.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": "fregante/github-url-detection",
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://fregante.github.io/github-url-detection/)
8
- - See the code and expected URLs for [every detection](https://github.com/fregante/github-url-detection/blob/main/index.ts)
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/fregante/github-url-detection/issues/1';
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/fregante/github-url-detection/pulls'))) {
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
  ```