github-url-detection 11.1.1 → 11.1.3
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 +3 -0
- package/distribution/index.js +22 -5
- package/package.json +1 -1
package/distribution/index.d.ts
CHANGED
|
@@ -274,6 +274,9 @@ export declare const hasWikiPageEditor: (url?: URL | HTMLAnchorElement | Locatio
|
|
|
274
274
|
export declare const isRepo: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
275
275
|
export declare const hasRepoHeader: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
276
276
|
export declare const isEmptyRepoRoot: () => boolean;
|
|
277
|
+
/**
|
|
278
|
+
* @deprecated Doesn't work anymore. Use `isEmptyRepoRoot` or API instead.
|
|
279
|
+
*/
|
|
277
280
|
export declare const isEmptyRepo: () => boolean;
|
|
278
281
|
export declare const isPublicRepo: () => boolean;
|
|
279
282
|
export declare const isArchivedRepo: () => boolean;
|
package/distribution/index.js
CHANGED
|
@@ -29,7 +29,11 @@ var isNewRelease = (url = location) => getRepo(url)?.path === "releases/new";
|
|
|
29
29
|
var isNewWikiPage = (url = location) => isRepoWiki(url) && getCleanPathname(url).endsWith("/_new");
|
|
30
30
|
var isNotifications = (url = location) => getCleanPathname(url) === "notifications";
|
|
31
31
|
var isOrganizationProfile = () => exists('meta[name="hovercard-subject-tag"][content^="organization"]');
|
|
32
|
-
var isOrganizationRepo = () => exists(
|
|
32
|
+
var isOrganizationRepo = () => exists([
|
|
33
|
+
'qbsearch-input[data-current-repository][data-current-org]:not([data-current-repository=""], [data-current-org=""])',
|
|
34
|
+
// TODO: Remove after June 2026
|
|
35
|
+
'.AppHeader-context-full [data-hovercard-type="organization"]'
|
|
36
|
+
].join(","));
|
|
33
37
|
var isTeamDiscussion = (url = location) => Boolean(getOrg(url)?.path.startsWith("teams"));
|
|
34
38
|
var isOwnUserProfile = () => getCleanPathname() === getLoggedInUser();
|
|
35
39
|
var isOwnOrganizationProfile = () => isOrganizationProfile() && !exists('[href*="contact/report-abuse?report="]');
|
|
@@ -53,7 +57,8 @@ var getStateLabel = () => $([
|
|
|
53
57
|
// Old view
|
|
54
58
|
// React versions
|
|
55
59
|
'[class^="StateLabel"]',
|
|
56
|
-
|
|
60
|
+
// TODO: Remove after July 2026
|
|
61
|
+
'[class^="prc-StateLabel-StateLabel"]'
|
|
57
62
|
].join(","))?.textContent?.trim();
|
|
58
63
|
var isMergedPR = () => getStateLabel() === "Merged";
|
|
59
64
|
var isDraftPR = () => getStateLabel() === "Draft";
|
|
@@ -81,7 +86,12 @@ var isRepo = (url = location) => {
|
|
|
81
86
|
return Boolean(user && repo && !reservedNames.includes(user) && !url.hostname.startsWith("gist.") && extra !== "generate");
|
|
82
87
|
};
|
|
83
88
|
var hasRepoHeader = (url = location) => isRepo(url) && !isRepoSearch(url);
|
|
84
|
-
var isEmptyRepoRoot = () => isRepoHome() &&
|
|
89
|
+
var isEmptyRepoRoot = () => isRepoHome() && exists([
|
|
90
|
+
// If you don't have write access
|
|
91
|
+
".blankslate-icon",
|
|
92
|
+
// If you have write access
|
|
93
|
+
"#empty-setup-clone-url"
|
|
94
|
+
].join(","));
|
|
85
95
|
var isEmptyRepo = () => exists('[aria-label="Cannot fork because repository is empty."]');
|
|
86
96
|
var isPublicRepo = () => exists('meta[name="octolytics-dimension-repository_public"][content="true"]');
|
|
87
97
|
var isArchivedRepo = () => Boolean(isRepo() && $("main > .flash-warn")?.textContent.includes("archived"));
|
|
@@ -162,7 +172,7 @@ var doesLookLikeAProfile = (string) => typeof string === "string" && string.leng
|
|
|
162
172
|
var isProfile = (url = location) => !isGist(url) && doesLookLikeAProfile(getCleanPathname(url));
|
|
163
173
|
var isGistProfile = (url = location) => doesLookLikeAProfile(getCleanGistPathname(url));
|
|
164
174
|
var isUserProfile = () => isProfile() && !isOrganizationProfile();
|
|
165
|
-
var isPrivateUserProfile = () => isUserProfile() &&
|
|
175
|
+
var isPrivateUserProfile = () => isUserProfile() && exists("#user-private-profile-frame");
|
|
166
176
|
var isUserProfileMainTab = () => isUserProfile() && !new URLSearchParams(location.search).has("tab");
|
|
167
177
|
var isUserProfileRepoTab = (url = location) => isProfile(url) && new URLSearchParams(url.search).get("tab") === "repositories";
|
|
168
178
|
var isUserProfileStarsTab = (url = location) => isProfile(url) && new URLSearchParams(url.search).get("tab") === "stars";
|
|
@@ -180,7 +190,14 @@ var isActionRun = (url = location) => /^(actions\/)?runs/.test(getRepo(url)?.pat
|
|
|
180
190
|
var isNewAction = (url = location) => getRepo(url)?.path === "actions/new";
|
|
181
191
|
var isRepositoryActions = (url = location) => /^actions(\/workflows\/.+\.ya?ml)?$/.test(getRepo(url)?.path);
|
|
182
192
|
var isUserTheOrganizationOwner = () => isOrganizationProfile() && exists('[aria-label="Organization"] [data-tab-item="org-header-settings-tab"]');
|
|
183
|
-
var canUserAdminRepo = () =>
|
|
193
|
+
var canUserAdminRepo = () => {
|
|
194
|
+
const repo = getRepo();
|
|
195
|
+
return Boolean(repo && exists(`:is(${[
|
|
196
|
+
".GlobalNav",
|
|
197
|
+
// Remove after June 2026
|
|
198
|
+
".js-repo-nav"
|
|
199
|
+
].join(",")}) a[href="/${repo.nameWithOwner}/settings"]`));
|
|
200
|
+
};
|
|
184
201
|
var isNewRepo = (url = location) => !isGist(url) && (url.pathname === "/new" || /^organizations\/[^/]+\/repositories\/new$/.test(getCleanPathname(url)));
|
|
185
202
|
var isNewRepoTemplate = (url = location) => Boolean(url.pathname.split("/")[3] === "generate");
|
|
186
203
|
var getLoggedInUser = () => $('meta[name="user-login"]')?.getAttribute("content") ?? void 0;
|