github-url-detection 5.7.1 → 5.8.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.
@@ -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;
@@ -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" === document.title;
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
 
@@ -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"]');
@@ -310,7 +316,7 @@ 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) || isNewRelease(url) || isDiscussion(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
 
@@ -378,4 +384,4 @@ const utils = {
378
384
  getRepositoryInfo: getRepo
379
385
  };
380
386
 
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 };
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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "github-url-detection",
3
- "version": "5.7.1",
3
+ "version": "5.8.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,