github-url-detection 8.1.1 → 8.2.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 +1 -0
- package/distribution/index.js +3 -1
- package/package.json +18 -27
package/distribution/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare const is404: () => boolean;
|
|
2
2
|
export declare const is500: () => boolean;
|
|
3
3
|
export declare const isPasswordConfirmation: () => boolean;
|
|
4
|
+
export declare const isLoggedIn: () => boolean;
|
|
4
5
|
export declare const isBlame: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
5
6
|
export declare const isCommit: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
6
7
|
export declare const isCommitList: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
package/distribution/index.js
CHANGED
|
@@ -289,6 +289,7 @@ const exists = (selector) => Boolean($(selector));
|
|
|
289
289
|
const is404 = () => /^(Page|File) not found · GitHub/.test(document.title);
|
|
290
290
|
const is500 = () => document.title === "Server Error · GitHub" || document.title === "Unicorn! · GitHub" || document.title === "504 Gateway Time-out";
|
|
291
291
|
const isPasswordConfirmation = () => document.title === "Confirm password" || document.title === "Confirm access";
|
|
292
|
+
const isLoggedIn = () => exists("body.logged-in");
|
|
292
293
|
const isBlame = (url = location) => Boolean(getRepo(url)?.path.startsWith("blame/"));
|
|
293
294
|
const isCommit = (url = location) => isSingleCommit(url) || isPRCommit(url);
|
|
294
295
|
const isCommitList = (url = location) => isRepoCommitList(url) || isPRCommitList(url);
|
|
@@ -419,7 +420,7 @@ const isUserTheOrganizationOwner = () => isOrganizationProfile() && exists('[ari
|
|
|
419
420
|
const canUserEditRepo = () => isRepo() && exists('.reponav-item[href$="/settings"], [data-tab-item$="settings-tab"]');
|
|
420
421
|
const isNewRepo = (url = location) => url.pathname === "/new" || /^organizations\/[^/]+\/repositories\/new$/.test(getCleanPathname(url));
|
|
421
422
|
const isNewRepoTemplate = (url = location) => Boolean(url.pathname.split("/")[3] === "generate");
|
|
422
|
-
const getUsername = () => $('meta[name="user-login"]')?.getAttribute("content");
|
|
423
|
+
const getUsername = () => $('meta[name="user-login"]')?.getAttribute("content") ?? void 0;
|
|
423
424
|
const getCleanPathname = (url = location) => url.pathname.replaceAll(/\/+/g, "/").slice(1, url.pathname.endsWith("/") ? -1 : void 0);
|
|
424
425
|
const getCleanGistPathname = (url = location) => {
|
|
425
426
|
const pathname = getCleanPathname(url);
|
|
@@ -513,6 +514,7 @@ export {
|
|
|
513
514
|
isIssue,
|
|
514
515
|
isIssueOrPRList,
|
|
515
516
|
isLabelList,
|
|
517
|
+
isLoggedIn,
|
|
516
518
|
isMarketplaceAction,
|
|
517
519
|
isMergedPR,
|
|
518
520
|
isMilestone,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "github-url-detection",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.2.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",
|
|
@@ -27,15 +27,15 @@
|
|
|
27
27
|
"build": "run-p build:*",
|
|
28
28
|
"build:vite": "vite build",
|
|
29
29
|
"build:typescript": "tsc --declaration --emitDeclarationOnly",
|
|
30
|
-
"demo
|
|
31
|
-
"demo:test": "svelte-check",
|
|
32
|
-
"demo:watch": "vite preview demo & vite build demo --watch # vite serve isn't real",
|
|
30
|
+
"build:demo": "vite build demo",
|
|
33
31
|
"prepack": "npm run build",
|
|
34
|
-
"test": "run-p build test
|
|
35
|
-
"test:unit": "
|
|
36
|
-
"
|
|
32
|
+
"test": "run-p build test:* xo",
|
|
33
|
+
"test:unit": "vitest",
|
|
34
|
+
"test:demo": "svelte-check",
|
|
35
|
+
"watch": "run-p watch:*",
|
|
37
36
|
"watch:typescript": "tsc --watch --noEmit",
|
|
38
|
-
"watch:test:unit": "run
|
|
37
|
+
"watch:test:unit": "npm run test:unit -- --watch",
|
|
38
|
+
"watch:demo": "vite preview demo & npm run build:demo -- --watch # vite serve isn't real",
|
|
39
39
|
"xo": "xo"
|
|
40
40
|
},
|
|
41
41
|
"xo": {
|
|
@@ -49,32 +49,23 @@
|
|
|
49
49
|
],
|
|
50
50
|
"rules": {
|
|
51
51
|
"@typescript-eslint/triple-slash-reference": "off",
|
|
52
|
-
"@typescript-eslint/
|
|
53
|
-
"@typescript-eslint/no-non-null-assertion": "off",
|
|
54
|
-
"@typescript-eslint/no-unsafe-member-access": "off",
|
|
55
|
-
"@typescript-eslint/no-non-null-asserted-optional-chain": "off",
|
|
56
|
-
"@typescript-eslint/naming-convention": "off",
|
|
57
|
-
"n/prefer-global/process": "off"
|
|
52
|
+
"@typescript-eslint/naming-convention": "off"
|
|
58
53
|
}
|
|
59
54
|
}
|
|
60
|
-
]
|
|
61
|
-
"rules": {
|
|
62
|
-
"camelcase": "off"
|
|
63
|
-
}
|
|
55
|
+
]
|
|
64
56
|
},
|
|
65
57
|
"devDependencies": {
|
|
66
|
-
"@sindresorhus/tsconfig": "^
|
|
67
|
-
"@sveltejs/vite-plugin-svelte": "^
|
|
68
|
-
"bun": "^1.0.3",
|
|
69
|
-
"bun-types": "^1.0.3",
|
|
58
|
+
"@sindresorhus/tsconfig": "^5.0.0",
|
|
59
|
+
"@sveltejs/vite-plugin-svelte": "^3.1.1",
|
|
70
60
|
"github-reserved-names": "^2.0.5",
|
|
71
61
|
"npm-run-all": "^4.1.5",
|
|
72
62
|
"strip-indent": "^4.0.0",
|
|
73
|
-
"svelte": "^4.2.
|
|
74
|
-
"svelte-check": "^3.
|
|
75
|
-
"typescript": "^5.
|
|
76
|
-
"vite": "^
|
|
77
|
-
"
|
|
63
|
+
"svelte": "^4.2.17",
|
|
64
|
+
"svelte-check": "^3.8.0",
|
|
65
|
+
"typescript": "^5.4.5",
|
|
66
|
+
"vite": "^5.2.12",
|
|
67
|
+
"vitest": "^1.6.0",
|
|
68
|
+
"xo": "^0.58.0"
|
|
78
69
|
},
|
|
79
70
|
"engines": {
|
|
80
71
|
"node": ">=18"
|