github-url-detection 8.1.0 → 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.
@@ -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;
@@ -1,4 +1,6 @@
1
1
  const reservedNames = [
2
+ "300",
3
+ "302",
2
4
  "400",
3
5
  "401",
4
6
  "402",
@@ -43,6 +45,10 @@ const reservedNames = [
43
45
  "509",
44
46
  "510",
45
47
  "511",
48
+ "693",
49
+ "694",
50
+ "695",
51
+ "900",
46
52
  "about",
47
53
  "access",
48
54
  "account",
@@ -68,6 +74,7 @@ const reservedNames = [
68
74
  "central",
69
75
  "certification",
70
76
  "changelog",
77
+ "chat",
71
78
  "cla",
72
79
  "cloud",
73
80
  "codereview",
@@ -86,6 +93,7 @@ const reservedNames = [
86
93
  "customer-stories",
87
94
  "customer",
88
95
  "customers",
96
+ "dashboard-feed",
89
97
  "dashboard",
90
98
  "dashboards",
91
99
  "design",
@@ -281,13 +289,14 @@ const exists = (selector) => Boolean($(selector));
281
289
  const is404 = () => /^(Page|File) not found · GitHub/.test(document.title);
282
290
  const is500 = () => document.title === "Server Error · GitHub" || document.title === "Unicorn! · GitHub" || document.title === "504 Gateway Time-out";
283
291
  const isPasswordConfirmation = () => document.title === "Confirm password" || document.title === "Confirm access";
292
+ const isLoggedIn = () => exists("body.logged-in");
284
293
  const isBlame = (url = location) => Boolean(getRepo(url)?.path.startsWith("blame/"));
285
294
  const isCommit = (url = location) => isSingleCommit(url) || isPRCommit(url);
286
295
  const isCommitList = (url = location) => isRepoCommitList(url) || isPRCommitList(url);
287
296
  const isRepoCommitList = (url = location) => Boolean(getRepo(url)?.path.startsWith("commits"));
288
297
  const isCompare = (url = location) => Boolean(getRepo(url)?.path.startsWith("compare"));
289
298
  const isCompareWikiPage = (url = location) => isRepoWiki(url) && getCleanPathname(url).split("/").slice(3, 5).includes("_compare");
290
- const isDashboard = (url = location) => !isGist(url) && /^$|^(orgs\/[^/]+\/)?dashboard(\/|$)/.test(getCleanPathname(url));
299
+ const isDashboard = (url = location) => !isGist(url) && /^$|^(orgs\/[^/]+\/)?dashboard(-feed)?(\/|$)/.test(getCleanPathname(url));
291
300
  const isEnterprise = (url = location) => url.hostname !== "github.com" && url.hostname !== "gist.github.com";
292
301
  const isGist = (url = location) => typeof getCleanGistPathname(url) === "string";
293
302
  const isGlobalIssueOrPRList = (url = location) => ["issues", "pulls"].includes(url.pathname.split("/", 2)[1]);
@@ -411,7 +420,7 @@ const isUserTheOrganizationOwner = () => isOrganizationProfile() && exists('[ari
411
420
  const canUserEditRepo = () => isRepo() && exists('.reponav-item[href$="/settings"], [data-tab-item$="settings-tab"]');
412
421
  const isNewRepo = (url = location) => url.pathname === "/new" || /^organizations\/[^/]+\/repositories\/new$/.test(getCleanPathname(url));
413
422
  const isNewRepoTemplate = (url = location) => Boolean(url.pathname.split("/")[3] === "generate");
414
- const getUsername = () => $('meta[name="user-login"]')?.getAttribute("content");
423
+ const getUsername = () => $('meta[name="user-login"]')?.getAttribute("content") ?? void 0;
415
424
  const getCleanPathname = (url = location) => url.pathname.replaceAll(/\/+/g, "/").slice(1, url.pathname.endsWith("/") ? -1 : void 0);
416
425
  const getCleanGistPathname = (url = location) => {
417
426
  const pathname = getCleanPathname(url);
@@ -505,6 +514,7 @@ export {
505
514
  isIssue,
506
515
  isIssueOrPRList,
507
516
  isLabelList,
517
+ isLoggedIn,
508
518
  isMarketplaceAction,
509
519
  isMergedPR,
510
520
  isMilestone,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "github-url-detection",
3
- "version": "8.1.0",
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",
@@ -24,18 +24,18 @@
24
24
  "distribution/index.d.ts"
25
25
  ],
26
26
  "scripts": {
27
- "ava": "ava --timeout 30s",
28
27
  "build": "run-p build:*",
29
28
  "build:vite": "vite build",
30
29
  "build:typescript": "tsc --declaration --emitDeclarationOnly",
31
- "demo:build": "vite build demo",
32
- "demo:test": "svelte-check",
33
- "demo:watch": "vite preview demo & vite build demo --watch # vite serve isn't real",
30
+ "build:demo": "vite build demo",
34
31
  "prepack": "npm run build",
35
- "test": "run-p build ava xo",
36
- "watch": "run-p watch:typescript demo:watch # vite watch doesn’t generate the lib, so just use the demo",
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:ava": "run-p 'ava -- --watch' 'watch:typescript -- --watch'",
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": {
@@ -48,41 +48,24 @@
48
48
  "*.ts"
49
49
  ],
50
50
  "rules": {
51
- "ava/assertion-arguments": "off",
52
- "@typescript-eslint/dot-notation": "off",
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"
51
+ "@typescript-eslint/triple-slash-reference": "off",
52
+ "@typescript-eslint/naming-convention": "off"
58
53
  }
59
54
  }
60
- ],
61
- "rules": {
62
- "camelcase": "off"
63
- }
64
- },
65
- "ava": {
66
- "extensions": {
67
- "ts": "module"
68
- },
69
- "nodeArguments": [
70
- "--loader=@esbuild-kit/esm-loader"
71
55
  ]
72
56
  },
73
57
  "devDependencies": {
74
- "@esbuild-kit/esm-loader": "^2.5.5",
75
- "@sindresorhus/tsconfig": "^3.0.1",
76
- "@sveltejs/vite-plugin-svelte": "^2.4.3",
77
- "ava": "^5.3.1",
78
- "github-reserved-names": "^2.0.4",
58
+ "@sindresorhus/tsconfig": "^5.0.0",
59
+ "@sveltejs/vite-plugin-svelte": "^3.1.1",
60
+ "github-reserved-names": "^2.0.5",
79
61
  "npm-run-all": "^4.1.5",
80
62
  "strip-indent": "^4.0.0",
81
- "svelte": "^4.1.2",
82
- "svelte-check": "^3.4.6",
83
- "typescript": "^5.1.6",
84
- "vite": "^4.4.7",
85
- "xo": "^0.55.0"
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"
86
69
  },
87
70
  "engines": {
88
71
  "node": ">=18"