github-url-detection 6.1.0 → 7.0.1-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.
@@ -113,7 +113,7 @@ export declare const isUserTheOrganizationOwner: () => boolean;
113
113
  export declare const canUserEditRepo: () => boolean;
114
114
  export declare const isNewRepo: (url?: URL | HTMLAnchorElement | Location) => boolean;
115
115
  export declare const isNewRepoTemplate: (url?: URL | HTMLAnchorElement | Location) => boolean;
116
- export interface RepositoryInfo {
116
+ export declare type RepositoryInfo = {
117
117
  owner: string;
118
118
  name: string;
119
119
  /** The 'user/repo' part from an URL */
@@ -123,7 +123,7 @@ export interface RepositoryInfo {
123
123
  @example '/user/repo/' -> ''
124
124
  @example '/settings/token/' -> undefined */
125
125
  path: string;
126
- }
126
+ };
127
127
  export declare const utils: {
128
128
  getUsername: () => string | undefined;
129
129
  getCleanPathname: (url?: URL | HTMLAnchorElement | Location) => string;
@@ -305,13 +305,13 @@ const isNewWikiPage = (url = location) => isRepoWiki(url) && getCleanPathname(ur
305
305
  const isNotifications = (url = location) => getCleanPathname(url) === "notifications";
306
306
  const isOrganizationProfile = () => exists('meta[name="hovercard-subject-tag"][content^="organization"]');
307
307
  const isOrganizationRepo = () => Boolean(document.querySelector("[data-owner-scoped-search-url]")?.dataset["ownerScopedSearchUrl"].startsWith("/org"));
308
- const isTeamDiscussion = (url = location) => /^orgs\/[^/]+\/teams\/[^/]+($|\/discussions)/.test(getCleanPathname(url));
308
+ const isTeamDiscussion = (url = location) => Boolean(getOrg(url)?.path.startsWith("teams"));
309
309
  const isOwnUserProfile = () => getCleanPathname() === getUsername();
310
310
  const isOwnOrganizationProfile = () => isOrganizationProfile() && !exists('[href*="contact/report-abuse?report="]');
311
311
  const isProject = (url = location) => /^projects\/\d+/.test(getRepo(url)?.path);
312
312
  const isProjects = (url = location) => getRepo(url)?.path === "projects";
313
- const isDiscussion = (url = location) => /^discussions\/\d+/.test(getRepo(url)?.path);
314
- const isDiscussionList = (url = location) => getRepo(url)?.path === "discussions";
313
+ const isDiscussion = (url = location) => /^discussions\/\d+/.test(getRepo(url)?.path ?? getOrg(url)?.path);
314
+ const isDiscussionList = (url = location) => getRepo(url)?.path === "discussions" || getOrg(url)?.path === "discussions";
315
315
  const isPR = (url = location) => /^pull\/\d+/.test(getRepo(url)?.path) && !isPRConflicts(url);
316
316
  const isPRConflicts = (url = location) => /^pull\/\d+\/conflicts/.test(getRepo(url)?.path);
317
317
  const isPRList = (url = location) => url.pathname === "/pulls" || getRepo(url)?.path === "pulls";
@@ -413,6 +413,13 @@ const getCleanGistPathname = (url = location) => {
413
413
  const [gist, ...parts] = pathname.split("/");
414
414
  return gist === "gist" ? parts.join("/") : void 0;
415
415
  };
416
+ const getOrg = (url = location) => {
417
+ const [, orgs, name, ...path] = url.pathname.split("/");
418
+ if (orgs === "orgs" && name) {
419
+ return { name, path: path.join("/") };
420
+ }
421
+ return void 0;
422
+ };
416
423
  const getRepo = (url) => {
417
424
  if (!url) {
418
425
  const canonical = document.querySelector('[property="og:url"]');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "github-url-detection",
3
- "version": "6.1.0",
3
+ "version": "7.0.1-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",
@@ -16,8 +16,9 @@
16
16
  "author": "Federico Brigante <me@fregante.com> (https://fregante.com)",
17
17
  "sideEffects": false,
18
18
  "type": "module",
19
- "main": "distribution/index.js",
20
- "module": "distribution/index.js",
19
+ "exports": "./distribution/index.js",
20
+ "main": "./distribution/index.js",
21
+ "types": "./distribution/index.d.ts",
21
22
  "files": [
22
23
  "distribution/index.js",
23
24
  "distribution/index.d.ts"
@@ -27,9 +28,9 @@
27
28
  "build": "run-p build:*",
28
29
  "build:vite": "vite build",
29
30
  "build:typescript": "tsc --declaration --emitDeclarationOnly",
30
- "demo:build": "vite build demo --config demo/vite.config.js",
31
+ "demo:build": "vite build demo",
31
32
  "demo:test": "svelte-check",
32
- "demo:watch": "vite serve demo --config demo/vite.config.js",
33
+ "demo:watch": "vite preview demo & vite build demo --watch # vite serve isn't real",
33
34
  "prepack": "npm run build",
34
35
  "test": "run-p build ava xo",
35
36
  "watch": "run-p watch:typescript demo:watch # vite watch doesn’t generate the lib, so just use the demo",
@@ -66,26 +67,25 @@
66
67
  "ts": "module"
67
68
  },
68
69
  "nodeArguments": [
69
- "--loader=esbuild-node-loader",
70
- "--experimental-specifier-resolution=node"
70
+ "--loader=@esbuild-kit/esm-loader"
71
71
  ]
72
72
  },
73
73
  "devDependencies": {
74
+ "@esbuild-kit/esm-loader": "^2.5.0",
74
75
  "@sindresorhus/tsconfig": "^3.0.1",
75
- "@sveltejs/vite-plugin-svelte": "^1.0.1",
76
- "ava": "^4.3.1",
77
- "esbuild-node-loader": "^0.8.0",
76
+ "@sveltejs/vite-plugin-svelte": "^1.1.0",
77
+ "ava": "^5.0.1",
78
78
  "github-reserved-names": "^2.0.4",
79
79
  "npm-run-all": "^4.1.5",
80
80
  "strip-indent": "^4.0.0",
81
- "svelte": "^3.49.0",
82
- "svelte-check": "^2.8.0",
81
+ "svelte": "^3.52.0",
82
+ "svelte-check": "^2.9.2",
83
83
  "tslib": "^2.4.0",
84
- "typescript": "^4.7.4",
85
- "vite": "^3.0.2",
86
- "xo": "^0.51.0"
84
+ "typescript": "^4.8.4",
85
+ "vite": "^3.1.8",
86
+ "xo": "^0.52.4"
87
87
  },
88
88
  "engines": {
89
- "node": ">=14"
89
+ "node": ">=18"
90
90
  }
91
91
  }