github-url-detection 5.4.0 → 5.7.1
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 -1
- package/distribution/index.js +26 -9
- package/package.json +1 -1
- package/readme.md +1 -1
package/distribution/index.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export declare const isOrganizationDiscussion: (url?: URL | HTMLAnchorElement |
|
|
|
28
28
|
export declare const isOwnUserProfile: () => boolean;
|
|
29
29
|
export declare const isOwnOrganizationProfile: () => boolean;
|
|
30
30
|
export declare const isProject: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
31
|
+
export declare const isProjects: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
31
32
|
export declare const isDiscussion: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
32
33
|
export declare const isDiscussionList: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
33
34
|
export declare const isPR: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
@@ -45,7 +46,11 @@ export declare const isDraftPR: () => boolean;
|
|
|
45
46
|
export declare const isOpenPR: () => boolean;
|
|
46
47
|
export declare const isMergedPR: () => boolean;
|
|
47
48
|
export declare const isClosedPR: () => boolean;
|
|
49
|
+
export declare const isReleases: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
50
|
+
export declare const isTags: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
51
|
+
export declare const isSingleTag: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
48
52
|
export declare const isReleasesOrTags: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
53
|
+
export declare const isDeletingFile: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
49
54
|
export declare const isEditingFile: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
50
55
|
export declare const isEditingRelease: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
51
56
|
export declare const isEditingWikiPage: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
@@ -81,7 +86,6 @@ export declare const isUserProfileRepoTab: (url?: URL | HTMLAnchorElement | Loca
|
|
|
81
86
|
export declare const isUserProfileStarsTab: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
82
87
|
export declare const isUserProfileFollowersTab: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
83
88
|
export declare const isUserProfileFollowingTab: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
84
|
-
export declare const isSingleTag: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
85
89
|
export declare const hasComments: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
86
90
|
export declare const hasRichTextEditor: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
87
91
|
export declare const hasCode: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
package/distribution/index.js
CHANGED
|
@@ -98,6 +98,11 @@ const isProject = (url = location) => {
|
|
|
98
98
|
return /^projects\/\d+/.test(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
|
|
99
99
|
};
|
|
100
100
|
|
|
101
|
+
const isProjects = (url = location) => {
|
|
102
|
+
var _a;
|
|
103
|
+
return "projects" === (null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
|
|
104
|
+
};
|
|
105
|
+
|
|
101
106
|
const isDiscussion = (url = location) => {
|
|
102
107
|
var _a;
|
|
103
108
|
return /^discussions\/\d+/.test(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
|
|
@@ -157,9 +162,26 @@ const isMergedPR = () => exists('#partial-discussion-header [title="Status: Merg
|
|
|
157
162
|
|
|
158
163
|
const isClosedPR = () => exists('#partial-discussion-header [title="Status: Closed"], #partial-discussion-header [title="Status: Merged"]');
|
|
159
164
|
|
|
160
|
-
const
|
|
165
|
+
const isReleases = (url = location) => {
|
|
166
|
+
var _a;
|
|
167
|
+
return "releases" === (null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
const isTags = (url = location) => {
|
|
171
|
+
var _a;
|
|
172
|
+
return "tags" === (null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
const isSingleTag = (url = location) => {
|
|
176
|
+
var _a;
|
|
177
|
+
return /^(releases\/tag)/.test(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const isReleasesOrTags = (url = location) => isReleases(url) || isTags(url) || isSingleTag(url);
|
|
181
|
+
|
|
182
|
+
const isDeletingFile = (url = location) => {
|
|
161
183
|
var _a;
|
|
162
|
-
return
|
|
184
|
+
return Boolean(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path.startsWith("delete"));
|
|
163
185
|
};
|
|
164
186
|
|
|
165
187
|
const isEditingFile = (url = location) => {
|
|
@@ -286,11 +308,6 @@ const isUserProfileFollowersTab = (url = location) => isProfile(url) && "followe
|
|
|
286
308
|
|
|
287
309
|
const isUserProfileFollowingTab = (url = location) => isProfile(url) && "following" === new URLSearchParams(url.search).get("tab");
|
|
288
310
|
|
|
289
|
-
const isSingleTag = (url = location) => {
|
|
290
|
-
var _a;
|
|
291
|
-
return /^(releases\/tag)/.test(null === (_a = getRepo(url)) || void 0 === _a ? void 0 : _a.path);
|
|
292
|
-
};
|
|
293
|
-
|
|
294
311
|
const hasComments = (url = location) => isPR(url) || isIssue(url) || isCommit(url) || isOrganizationDiscussion(url) || isSingleGist(url);
|
|
295
312
|
|
|
296
313
|
const hasRichTextEditor = (url = location) => hasComments(url) || isNewIssue(url) || isCompare(url) || isRepliesSettings(url) || isNewRelease(url) || isDiscussion(url);
|
|
@@ -334,7 +351,7 @@ const getUsername = () => {
|
|
|
334
351
|
return null === (_a = document.querySelector('meta[name="user-login"]')) || void 0 === _a ? void 0 : _a.getAttribute("content");
|
|
335
352
|
};
|
|
336
353
|
|
|
337
|
-
const getCleanPathname = (url = location) => url.pathname.slice(1, url.pathname.endsWith("/") ? -1 : void 0);
|
|
354
|
+
const getCleanPathname = (url = location) => url.pathname.replace(/\/+/g, "/").slice(1, url.pathname.endsWith("/") ? -1 : void 0);
|
|
338
355
|
|
|
339
356
|
const getRepo = url => {
|
|
340
357
|
if (!url) {
|
|
@@ -361,4 +378,4 @@ const utils = {
|
|
|
361
378
|
getRepositoryInfo: getRepo
|
|
362
379
|
};
|
|
363
380
|
|
|
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 };
|
|
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 };
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
Battle-tested by and extracted from the [Refined GitHub](https://github.com/sindresorhus/refined-github) extension.
|
|
6
6
|
|
|
7
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/
|
|
8
|
+
- See the code and expected URLs for [every detection](https://github.com/fregante/github-url-detection/blob/main/index.ts)
|
|
9
9
|
|
|
10
10
|
## Install
|
|
11
11
|
|