github-url-detection 9.0.3 → 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,31 +48,20 @@ 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 stateSelector = [
51
+ var getStateLabel = () => $([
52
52
  ".State",
53
- '[data-testid="header-state"]'
54
- ].join(",");
55
- var isDraftPR = () => $(stateSelector)?.textContent.trim() === "Draft";
56
- var isOpenPR = () => {
57
- if (!isPR()) {
58
- return false;
59
- }
60
- const status = $(stateSelector).textContent.trim();
53
+ // Old view
54
+ '[class^="StateLabel"]'
55
+ // React version
56
+ ].join(","))?.textContent?.trim();
57
+ var isMergedPR = () => getStateLabel() === "Merged";
58
+ var isDraftPR = () => getStateLabel() === "Draft";
59
+ var isOpenConversation = () => {
60
+ const status = getStateLabel();
61
61
  return status === "Open" || status === "Draft";
62
62
  };
63
- var isMergedPR = () => $(stateSelector)?.textContent.trim() === "Merged";
64
- var isClosedPR = () => {
65
- if (!isPR()) {
66
- return false;
67
- }
68
- const status = $(stateSelector).textContent.trim();
69
- return status === "Closed" || status === "Merged";
70
- };
71
- var isClosedIssue = () => {
72
- if (!isIssue()) {
73
- return false;
74
- }
75
- const status = $(stateSelector).textContent.trim();
63
+ var isClosedConversation = () => {
64
+ const status = getStateLabel();
76
65
  return status === "Closed" || status === "Closed as not planned";
77
66
  };
78
67
  var isReleases = (url = location) => getRepo(url)?.path === "releases";
@@ -234,8 +223,7 @@ export {
234
223
  isBlame,
235
224
  isBlank,
236
225
  isBranches,
237
- isClosedIssue,
238
- isClosedPR,
226
+ isClosedConversation,
239
227
  isCommit,
240
228
  isCommitList,
241
229
  isCompare,
@@ -276,7 +264,7 @@ export {
276
264
  isNewRepoTemplate,
277
265
  isNewWikiPage,
278
266
  isNotifications,
279
- isOpenPR,
267
+ isOpenConversation,
280
268
  isOrganizationProfile,
281
269
  isOrganizationRepo,
282
270
  isOwnOrganizationProfile,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "github-url-detection",
3
- "version": "9.0.3",
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",