github-url-detection 9.0.2 → 10.0.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.
@@ -45,11 +45,10 @@ export declare const isPRConversation: (url?: URL | HTMLAnchorElement | Location
45
45
  export declare const isPRCommitList: (url?: URL | HTMLAnchorElement | Location) => boolean;
46
46
  export declare const isPRFiles: (url?: URL | HTMLAnchorElement | Location) => boolean;
47
47
  export declare const isQuickPR: (url?: URL | HTMLAnchorElement | Location) => boolean;
48
- export declare const isDraftPR: () => boolean;
49
- export declare const isOpenPR: () => boolean;
50
48
  export declare const isMergedPR: () => boolean;
51
- export declare const isClosedPR: () => boolean;
52
- export declare const isClosedIssue: () => boolean;
49
+ export declare const isDraftPR: () => boolean;
50
+ export declare const isOpenConversation: () => boolean;
51
+ export declare const isClosedConversation: () => boolean;
53
52
  export declare const isReleases: (url?: URL | HTMLAnchorElement | Location) => boolean;
54
53
  export declare const isTags: (url?: URL | HTMLAnchorElement | Location) => boolean;
55
54
  export declare const isSingleReleaseOrTag: (url?: URL | HTMLAnchorElement | Location) => boolean;
@@ -48,24 +48,22 @@ var isPRConversation = (url = location) => /^pull\/\d+$/.test(getRepo(url)?.path
48
48
  var isPRCommitList = (url = location) => /^pull\/\d+\/commits$/.test(getRepo(url)?.path);
49
49
  var isPRFiles = (url = location) => /^pull\/\d+\/files/.test(getRepo(url)?.path) || isPRCommit(url);
50
50
  var isQuickPR = (url = location) => isCompare(url) && /[?&]quick_pull=1(&|$)/.test(url.search);
51
- var prStateSelector = [
51
+ var getStateLabel = () => $([
52
52
  ".State",
53
+ // Old view
53
54
  '[class^="StateLabel"]'
54
- ].join(",");
55
- var isDraftPR = () => $(prStateSelector).textContent.trim() === "Draft";
56
- var isOpenPR = () => {
57
- const status = $(prStateSelector).textContent.trim();
55
+ // React version
56
+ ].join(","))?.textContent?.trim();
57
+ var isMergedPR = () => getStateLabel() === "Merged";
58
+ var isDraftPR = () => getStateLabel() === "Draft";
59
+ var isOpenConversation = () => {
60
+ const status = getStateLabel();
58
61
  return status === "Open" || status === "Draft";
59
62
  };
60
- var isMergedPR = () => {
61
- const status = $(prStateSelector).textContent.trim();
62
- return status === "Merged";
63
+ var isClosedConversation = () => {
64
+ const status = getStateLabel();
65
+ return status === "Closed" || status === "Closed as not planned";
63
66
  };
64
- var isClosedPR = () => {
65
- const status = $(prStateSelector).textContent.trim();
66
- return status === "Closed" || status === "Merged";
67
- };
68
- var isClosedIssue = () => exists("#partial-discussion-header :is(.octicon-issue-closed, .octicon-skip)");
69
67
  var isReleases = (url = location) => getRepo(url)?.path === "releases";
70
68
  var isTags = (url = location) => getRepo(url)?.path === "tags";
71
69
  var isSingleReleaseOrTag = (url = location) => Boolean(getRepo(url)?.path.startsWith("releases/tag"));
@@ -225,8 +223,7 @@ export {
225
223
  isBlame,
226
224
  isBlank,
227
225
  isBranches,
228
- isClosedIssue,
229
- isClosedPR,
226
+ isClosedConversation,
230
227
  isCommit,
231
228
  isCommitList,
232
229
  isCompare,
@@ -267,7 +264,7 @@ export {
267
264
  isNewRepoTemplate,
268
265
  isNewWikiPage,
269
266
  isNotifications,
270
- isOpenPR,
267
+ isOpenConversation,
271
268
  isOrganizationProfile,
272
269
  isOrganizationRepo,
273
270
  isOwnOrganizationProfile,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "github-url-detection",
3
- "version": "9.0.2",
3
+ "version": "10.0.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",
@@ -28,6 +28,7 @@
28
28
  "build:esbuild": "esbuild index.ts --bundle --external:github-reserved-names --outdir=distribution --format=esm --drop-labels=TEST",
29
29
  "build:typescript": "tsc --declaration --emitDeclarationOnly",
30
30
  "build:demo": "vite build demo",
31
+ "fix": "xo --fix",
31
32
  "prepack": "npm run build",
32
33
  "test": "run-p build test:* xo",
33
34
  "test:unit": "vitest",