github-url-detection 11.0.0 → 11.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.
@@ -3,9 +3,7 @@ export declare const is404: () => boolean;
3
3
  export declare const is500: () => boolean;
4
4
  export declare const isPasswordConfirmation: () => boolean;
5
5
  export declare const isLoggedIn: () => boolean;
6
- /**
7
- * @example https://github.com/sindresorhus/refined-github/blame/master/package.json
8
- */
6
+ /** @example https://github.com/sindresorhus/refined-github/blame/master/package.json */
9
7
  export declare const isBlame: (url?: URL | HTMLAnchorElement | Location) => boolean;
10
8
  /**
11
9
  * @example https://github.com/sindresorhus/refined-github/commit/5b614b9035f2035b839f48b4db7bd5c3298d526f
@@ -100,13 +98,9 @@ export declare const isGist: (url?: URL | HTMLAnchorElement | Location) => boole
100
98
  * @example https://github.com/pulls/review-requested
101
99
  */
102
100
  export declare const isGlobalIssueOrPRList: (url?: URL | HTMLAnchorElement | Location) => boolean;
103
- /**
104
- * @example https://github.com/search?q=refined-github&ref=opensearch
105
- */
101
+ /** @example https://github.com/search?q=refined-github&ref=opensearch */
106
102
  export declare const isGlobalSearchResults: (url?: URL | HTMLAnchorElement | Location) => boolean;
107
- /**
108
- * @example https://github.com/sindresorhus/refined-github/issues/146
109
- */
103
+ /** @example https://github.com/sindresorhus/refined-github/issues/146 */
110
104
  export declare const isIssue: (url?: URL | HTMLAnchorElement | Location) => boolean;
111
105
  export declare const isIssueOrPRList: (url?: URL | HTMLAnchorElement | Location) => boolean;
112
106
  export declare const isConversation: (url?: URL | HTMLAnchorElement | Location) => boolean;
@@ -115,33 +109,19 @@ export declare const isConversation: (url?: URL | HTMLAnchorElement | Location)
115
109
  * @example https://github.com/sindresorhus/refined-github/labels/
116
110
  */
117
111
  export declare const isLabelList: (url?: URL | HTMLAnchorElement | Location) => boolean;
118
- /**
119
- * @example https://github.com/kubernetes/kubernetes/milestone/56
120
- */
112
+ /** @example https://github.com/kubernetes/kubernetes/milestone/56 */
121
113
  export declare const isMilestone: (url?: URL | HTMLAnchorElement | Location) => boolean;
122
- /**
123
- * @example https://github.com/sindresorhus/refined-github/milestones
124
- */
114
+ /** @example https://github.com/sindresorhus/refined-github/milestones */
125
115
  export declare const isMilestoneList: (url?: URL | HTMLAnchorElement | Location) => boolean;
126
- /**
127
- * @example https://github.com/sindresorhus/refined-github/new/main
128
- */
116
+ /** @example https://github.com/sindresorhus/refined-github/new/main */
129
117
  export declare const isNewFile: (url?: URL | HTMLAnchorElement | Location) => boolean;
130
- /**
131
- * @example https://github.com/sindresorhus/refined-github/issues/new
132
- */
118
+ /** @example https://github.com/sindresorhus/refined-github/issues/new */
133
119
  export declare const isNewIssue: (url?: URL | HTMLAnchorElement | Location) => boolean;
134
- /**
135
- * @example https://github.com/sindresorhus/refined-github/releases/new
136
- */
120
+ /** @example https://github.com/sindresorhus/refined-github/releases/new */
137
121
  export declare const isNewRelease: (url?: URL | HTMLAnchorElement | Location) => boolean;
138
- /**
139
- * @example https://github.com/tooomm/wikitest/wiki/_new
140
- */
122
+ /** @example https://github.com/tooomm/wikitest/wiki/_new */
141
123
  export declare const isNewWikiPage: (url?: URL | HTMLAnchorElement | Location) => boolean;
142
- /**
143
- * @example https://github.com/notifications
144
- */
124
+ /** @example https://github.com/notifications */
145
125
  export declare const isNotifications: (url?: URL | HTMLAnchorElement | Location) => boolean;
146
126
  export declare const isOrganizationProfile: () => boolean;
147
127
  export declare const isOrganizationRepo: () => boolean;
@@ -158,9 +138,7 @@ export declare const isOwnOrganizationProfile: () => boolean;
158
138
  * @example https://github.com/orgs/RSSNext/projects/3
159
139
  */
160
140
  export declare const isProject: (url?: URL | HTMLAnchorElement | Location) => boolean;
161
- /**
162
- * @example https://github.com/sindresorhus/refined-github/projects
163
- */
141
+ /** @example https://github.com/sindresorhus/refined-github/projects */
164
142
  export declare const isProjects: (url?: URL | HTMLAnchorElement | Location) => boolean;
165
143
  /**
166
144
  * @example https://github.com/tophf/mpiv/discussions/50
@@ -192,9 +170,7 @@ export declare const isDiscussionList: (url?: URL | HTMLAnchorElement | Location
192
170
  * @example https://github.com/sindresorhus/refined-github/pull/148
193
171
  */
194
172
  export declare const isPR: (url?: URL | HTMLAnchorElement | Location) => boolean;
195
- /**
196
- * @example https://github.com/sindresorhus/refined-github/pull/148/conflicts
197
- */
173
+ /** @example https://github.com/sindresorhus/refined-github/pull/148/conflicts */
198
174
  export declare const isPRConflicts: (url?: URL | HTMLAnchorElement | Location) => boolean;
199
175
  /**
200
176
  * Any `isIssueOrPRList` can display both issues and PRs, prefer that detection. `isPRList` only exists because this page has PR-specific filters like the "Reviews" dropdown
@@ -215,13 +191,9 @@ export declare const isPRList: (url?: URL | HTMLAnchorElement | Location) => boo
215
191
  export declare const isPRCommit: (url?: URL | HTMLAnchorElement | Location) => boolean;
216
192
  export declare const isPRCommit404: () => boolean;
217
193
  export declare const isPRFile404: () => boolean;
218
- /**
219
- * @example https://github.com/sindresorhus/refined-github/pull/148
220
- */
194
+ /** @example https://github.com/sindresorhus/refined-github/pull/148 */
221
195
  export declare const isPRConversation: (url?: URL | HTMLAnchorElement | Location) => boolean;
222
- /**
223
- * @example https://github.com/sindresorhus/refined-github/pull/148/commits
224
- */
196
+ /** @example https://github.com/sindresorhus/refined-github/pull/148/commits */
225
197
  export declare const isPRCommitList: (url?: URL | HTMLAnchorElement | Location) => boolean;
226
198
  /**
227
199
  * @example https://github.com/sindresorhus/refined-github/pull/148/commits/1e27d7998afdd3608d9fc3bf95ccf27fa5010641
@@ -279,14 +251,10 @@ export declare const isDeletingFile: (url?: URL | HTMLAnchorElement | Location)
279
251
  */
280
252
  export declare const isEditingFile: (url?: URL | HTMLAnchorElement | Location) => boolean;
281
253
  export declare const hasFileEditor: (url?: URL | HTMLAnchorElement | Location) => boolean;
282
- /**
283
- * @example https://github.com/sindresorhus/refined-github/releases/edit/v1.2.3
284
- */
254
+ /** @example https://github.com/sindresorhus/refined-github/releases/edit/v1.2.3 */
285
255
  export declare const isEditingRelease: (url?: URL | HTMLAnchorElement | Location) => boolean;
286
256
  export declare const hasReleaseEditor: (url?: URL | HTMLAnchorElement | Location) => boolean;
287
- /**
288
- * @example https://github.com/tooomm/wikitest/wiki/Getting-Started/_edit
289
- */
257
+ /** @example https://github.com/tooomm/wikitest/wiki/Getting-Started/_edit */
290
258
  export declare const isEditingWikiPage: (url?: URL | HTMLAnchorElement | Location) => boolean;
291
259
  export declare const hasWikiPageEditor: (url?: URL | HTMLAnchorElement | Location) => boolean;
292
260
  /**
@@ -377,9 +345,7 @@ export declare const isRepoSearch: (url?: URL | HTMLAnchorElement | Location) =>
377
345
  * @example https://github.com/sindresorhus/refined-github/settings/branches
378
346
  */
379
347
  export declare const isRepoSettings: (url?: URL | HTMLAnchorElement | Location) => boolean;
380
- /**
381
- * @example https://github.com/sindresorhus/refined-github/settings
382
- */
348
+ /** @example https://github.com/sindresorhus/refined-github/settings */
383
349
  export declare const isRepoMainSettings: (url?: URL | HTMLAnchorElement | Location) => boolean;
384
350
  /**
385
351
  * @example https://github.com/settings/replies
@@ -430,29 +396,55 @@ export declare const isSingleCommit: (url?: URL | HTMLAnchorElement | Location)
430
396
  * @example https://github.com/sindresorhus/refined-github/blob/master/.gitattributes
431
397
  * @example https://github.com/sindresorhus/refined-github/blob/fix-narrow-diff/distribution/content.css
432
398
  * @example https://github.com/sindresorhus/refined-github/blob/master/edit.txt
399
+ * @example https://github.com/sindresorhus/refined-github/blob/master/readme.md
400
+ * @example https://github.com/sindresorhus/refined-github/blob/master/README.markdown
401
+ * @example https://github.com/sindresorhus/refined-github/blob/main/docs/guide.mdown
402
+ * @example https://github.com/sindresorhus/refined-github/blob/main/CONTRIBUTING.mkdn
403
+ * @example https://github.com/sindresorhus/refined-github/blob/master/file.textile
404
+ * @example https://github.com/sindresorhus/refined-github/blob/master/file.rdoc
405
+ * @example https://github.com/sindresorhus/refined-github/blob/master/file.org
406
+ * @example https://github.com/sindresorhus/refined-github/blob/master/file.creole
407
+ * @example https://github.com/sindresorhus/refined-github/blob/master/file.mediawiki
408
+ * @example https://github.com/sindresorhus/refined-github/blob/master/file.wiki
409
+ * @example https://github.com/sindresorhus/refined-github/blob/master/file.rst
410
+ * @example https://github.com/sindresorhus/refined-github/blob/master/file.asciidoc
411
+ * @example https://github.com/sindresorhus/refined-github/blob/master/file.adoc
412
+ * @example https://github.com/sindresorhus/refined-github/blob/master/file.asc
413
+ * @example https://github.com/sindresorhus/refined-github/blob/master/file.pod
433
414
  */
434
415
  export declare const isSingleFile: (url?: URL | HTMLAnchorElement | Location) => boolean;
435
416
  /**
436
- * @example https://github.com/sindresorhus/refined-github/find/master
437
- */
417
+ * @example https://github.com/sindresorhus/refined-github/blob/master/readme.md
418
+ * @example https://github.com/sindresorhus/refined-github/blob/master/README.markdown
419
+ * @example https://github.com/sindresorhus/refined-github/blob/main/docs/guide.mdown
420
+ * @example https://github.com/sindresorhus/refined-github/blob/main/CONTRIBUTING.mkdn
421
+ * @example https://github.com/sindresorhus/refined-github/blob/master/file.textile
422
+ * @example https://github.com/sindresorhus/refined-github/blob/master/file.rdoc
423
+ * @example https://github.com/sindresorhus/refined-github/blob/master/file.org
424
+ * @example https://github.com/sindresorhus/refined-github/blob/master/file.creole
425
+ * @example https://github.com/sindresorhus/refined-github/blob/master/file.mediawiki
426
+ * @example https://github.com/sindresorhus/refined-github/blob/master/file.wiki
427
+ * @example https://github.com/sindresorhus/refined-github/blob/master/file.rst
428
+ * @example https://github.com/sindresorhus/refined-github/blob/master/file.asciidoc
429
+ * @example https://github.com/sindresorhus/refined-github/blob/master/file.adoc
430
+ * @example https://github.com/sindresorhus/refined-github/blob/master/file.asc
431
+ * @example https://github.com/sindresorhus/refined-github/blob/master/file.pod
432
+ */
433
+ export declare const isRenderedTextFile: (url?: URL | HTMLAnchorElement | Location) => boolean;
434
+ export declare const hasRenderedText: (url?: URL | HTMLAnchorElement | Location) => boolean;
435
+ /** @example https://github.com/sindresorhus/refined-github/find/master */
438
436
  export declare const isFileFinder: (url?: URL | HTMLAnchorElement | Location) => boolean;
439
437
  /**
440
438
  * @example https://github.com/fregante/GhostText/tree/3cacd7df71b097dc525d99c7aa2f54d31b02fcc8/chrome/scripts/InputArea
441
439
  * @example https://github.com/refined-github/refined-github/blob/some-non-existent-ref/source/features/bugs-tab.tsx
442
440
  */
443
441
  export declare const isRepoFile404: (url?: URL | HTMLAnchorElement | Location) => boolean;
444
- /**
445
- * @example https://github.com/sindresorhus/refined-github/network/members
446
- */
442
+ /** @example https://github.com/sindresorhus/refined-github/network/members */
447
443
  export declare const isRepoForksList: (url?: URL | HTMLAnchorElement | Location) => boolean;
448
- /**
449
- * @example https://github.com/sindresorhus/refined-github/network
450
- */
444
+ /** @example https://github.com/sindresorhus/refined-github/network */
451
445
  export declare const isRepoNetworkGraph: (url?: URL | HTMLAnchorElement | Location) => boolean;
452
446
  export declare const isForkedRepo: () => boolean;
453
- /**
454
- * @example https://github.com/refined-github/refined-github/fork
455
- */
447
+ /** @example https://github.com/refined-github/refined-github/fork */
456
448
  export declare const isForkingRepo: (url?: URL | HTMLAnchorElement | Location) => boolean;
457
449
  /**
458
450
  * @example https://gist.github.com/fregante/2205329b71218fa2c1d3
@@ -460,19 +452,20 @@ export declare const isForkingRepo: (url?: URL | HTMLAnchorElement | Location) =
460
452
  * @example https://gist.github.com/sindresorhus/0ea3c2845718a0a0f0beb579ff14f064
461
453
  */
462
454
  export declare const isSingleGist: (url?: URL | HTMLAnchorElement | Location) => boolean;
455
+ /** @example https://gist.github.com/kidonng/0d16c7f17045f486751fad1b602204a0/revisions */
456
+ export declare const isGistRevision: (url?: URL | HTMLAnchorElement | Location) => boolean;
463
457
  /**
464
- * @example https://gist.github.com/kidonng/0d16c7f17045f486751fad1b602204a0/revisions
458
+ * @example https://gist.github.com/fregante/2205329b71218fa2c1d3
459
+ * @example https://gist.github.com/sindresorhus/0ea3c2845718a0a0f0beb579ff14f064
465
460
  */
466
- export declare const isGistRevision: (url?: URL | HTMLAnchorElement | Location) => boolean;
461
+ export declare const isGistFile: (url?: URL | HTMLAnchorElement | Location) => boolean;
467
462
  /**
468
463
  * @example https://github.com/trending
469
464
  * @example https://github.com/trending/developers
470
465
  * @example https://github.com/trending/unknown
471
466
  */
472
467
  export declare const isTrending: (url?: URL | HTMLAnchorElement | Location) => boolean;
473
- /**
474
- * @example https://github.com/sindresorhus/refined-github/branches
475
- */
468
+ /** @example https://github.com/sindresorhus/refined-github/branches */
476
469
  export declare const isBranches: (url?: URL | HTMLAnchorElement | Location) => boolean;
477
470
  /**
478
471
  * @example https://github.com/fregante
@@ -556,6 +549,21 @@ export declare const hasCode: (url?: URL | HTMLAnchorElement | Location) => bool
556
549
  * @example https://github.com/sindresorhus/refined-github/blob/master/.gitattributes
557
550
  * @example https://github.com/sindresorhus/refined-github/blob/fix-narrow-diff/distribution/content.css
558
551
  * @example https://github.com/sindresorhus/refined-github/blob/master/edit.txt
552
+ * @example https://github.com/sindresorhus/refined-github/blob/master/readme.md
553
+ * @example https://github.com/sindresorhus/refined-github/blob/master/README.markdown
554
+ * @example https://github.com/sindresorhus/refined-github/blob/main/docs/guide.mdown
555
+ * @example https://github.com/sindresorhus/refined-github/blob/main/CONTRIBUTING.mkdn
556
+ * @example https://github.com/sindresorhus/refined-github/blob/master/file.textile
557
+ * @example https://github.com/sindresorhus/refined-github/blob/master/file.rdoc
558
+ * @example https://github.com/sindresorhus/refined-github/blob/master/file.org
559
+ * @example https://github.com/sindresorhus/refined-github/blob/master/file.creole
560
+ * @example https://github.com/sindresorhus/refined-github/blob/master/file.mediawiki
561
+ * @example https://github.com/sindresorhus/refined-github/blob/master/file.wiki
562
+ * @example https://github.com/sindresorhus/refined-github/blob/master/file.rst
563
+ * @example https://github.com/sindresorhus/refined-github/blob/master/file.asciidoc
564
+ * @example https://github.com/sindresorhus/refined-github/blob/master/file.adoc
565
+ * @example https://github.com/sindresorhus/refined-github/blob/master/file.asc
566
+ * @example https://github.com/sindresorhus/refined-github/blob/master/file.pod
559
567
  * @example https://github.com/sindresorhus/refined-github/blame/master/package.json
560
568
  */
561
569
  export declare const isRepoGitObject: (url?: URL | HTMLAnchorElement | Location) => boolean;
@@ -578,9 +586,7 @@ export declare const isActionJobRun: (url?: URL | HTMLAnchorElement | Location)
578
586
  * @example https://github.com/refined-github/github-url-detection/actions/runs/294962314
579
587
  */
580
588
  export declare const isActionRun: (url?: URL | HTMLAnchorElement | Location) => boolean;
581
- /**
582
- * @example https://github.com/sindresorhus/refined-github/actions/new
583
- */
589
+ /** @example https://github.com/sindresorhus/refined-github/actions/new */
584
590
  export declare const isNewAction: (url?: URL | HTMLAnchorElement | Location) => boolean;
585
591
  /**
586
592
  * @example https://github.com/refined-github/github-url-detection/actions
@@ -595,9 +601,7 @@ export declare const canUserAdminRepo: () => boolean;
595
601
  * @example https://github.com/organizations/npmhub/repositories/new
596
602
  */
597
603
  export declare const isNewRepo: (url?: URL | HTMLAnchorElement | Location) => boolean;
598
- /**
599
- * @example https://github.com/fregante/browser-extension-template/generate
600
- */
604
+ /** @example https://github.com/fregante/browser-extension-template/generate */
601
605
  export declare const isNewRepoTemplate: (url?: URL | HTMLAnchorElement | Location) => boolean;
602
606
  export type NameWithOwner = `${string}/${string}`;
603
607
  export type RepositoryInfo = {
@@ -51,8 +51,9 @@ var isQuickPR = (url = location) => isCompare(url) && /[?&]quick_pull=1(&|$)/.te
51
51
  var getStateLabel = () => $([
52
52
  ".State",
53
53
  // Old view
54
- '[class^="StateLabel"]'
55
- // React version
54
+ // React versions
55
+ '[class^="StateLabel"]',
56
+ '[data-testid="header-state"]'
56
57
  ].join(","))?.textContent?.trim();
57
58
  var isMergedPR = () => getStateLabel() === "Merged";
58
59
  var isDraftPR = () => getStateLabel() === "Draft";
@@ -141,6 +142,8 @@ var isRepoTree = (url = location) => _isRepoRoot(url) || Boolean(getRepo(url)?.p
141
142
  var isRepoWiki = (url = location) => Boolean(getRepo(url)?.path.startsWith("wiki"));
142
143
  var isSingleCommit = (url = location) => /^commit\/[\da-f]{5,40}$/.test(getRepo(url)?.path);
143
144
  var isSingleFile = (url = location) => Boolean(getRepo(url)?.path.startsWith("blob/"));
145
+ var isRenderedTextFile = (url = location) => isSingleFile(url) && /\.(md|markdown|mdown|mkdn|textile|rdoc|org|creole|mediawiki|wiki|rst|asciidoc|adoc|asc|pod)$/i.test(url.pathname);
146
+ var hasRenderedText = (url = location) => isRepoRoot(url) || isRenderedTextFile(url);
144
147
  var isFileFinder = (url = location) => Boolean(getRepo(url)?.path.startsWith("find/"));
145
148
  var isRepoFile404 = (url = location) => (isSingleFile(url) || isRepoTree(url)) && document.title.startsWith("File not found");
146
149
  var isRepoForksList = (url = location) => getRepo(url)?.path === "network/members";
@@ -149,6 +152,10 @@ var isForkedRepo = () => exists('meta[name="octolytics-dimension-repository_is_f
149
152
  var isForkingRepo = (url = location) => getRepo(url)?.path === "fork";
150
153
  var isSingleGist = (url = location) => /^[^/]+\/[\da-f]{20,32}(\/[\da-f]{40})?$/.test(getCleanGistPathname(url));
151
154
  var isGistRevision = (url = location) => /^[^/]+\/[\da-f]{20,32}\/revisions$/.test(getCleanGistPathname(url));
155
+ var isGistFile = (url = location) => {
156
+ const pathname = getCleanGistPathname(url);
157
+ return pathname?.replace(/[^/]/g, "").length === 1;
158
+ };
152
159
  var isTrending = (url = location) => url.pathname === "/trending" || url.pathname.startsWith("/trending/");
153
160
  var isBranches = (url = location) => Boolean(getRepo(url)?.path.startsWith("branches"));
154
161
  var doesLookLikeAProfile = (string) => typeof string === "string" && string.length > 0 && !string.includes("/") && !string.includes(".") && !reservedNames.includes(string);
@@ -233,6 +240,7 @@ export {
233
240
  hasFileEditor,
234
241
  hasFiles,
235
242
  hasReleaseEditor,
243
+ hasRenderedText,
236
244
  hasRepoHeader,
237
245
  hasRichTextEditor,
238
246
  hasWikiPageEditor,
@@ -265,6 +273,7 @@ export {
265
273
  isForkedRepo,
266
274
  isForkingRepo,
267
275
  isGist,
276
+ isGistFile,
268
277
  isGistProfile,
269
278
  isGistRevision,
270
279
  isGlobalIssueOrPRList,
@@ -310,6 +319,7 @@ export {
310
319
  isQuickPR,
311
320
  isReleases,
312
321
  isReleasesOrTags,
322
+ isRenderedTextFile,
313
323
  isRepliesSettings,
314
324
  isRepo,
315
325
  isRepoCommitList,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "github-url-detection",
3
- "version": "11.0.0",
3
+ "version": "11.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",
@@ -27,7 +27,7 @@
27
27
  "build": "run-p build:*",
28
28
  "build:esbuild": "esbuild index.ts --bundle --external:github-reserved-names --outdir=distribution --format=esm --drop-labels=TEST",
29
29
  "build:typescript": "tsc",
30
- "postbuild:typescript": "node add-examples-to-dts.ts",
30
+ "postbuild:typescript": "tsx add-examples-to-dts.ts",
31
31
  "build:demo": "vite build demo",
32
32
  "try": "esbuild index.ts --bundle --global-name=x --format=iife | pbcopy && echo 'Copied to clipboard'",
33
33
  "fix": "xo --fix",
@@ -54,6 +54,8 @@
54
54
  "strip-indent": "^4.1.1",
55
55
  "svelte": "^5.46.1",
56
56
  "svelte-check": "^4.3.5",
57
+ "ts-morph": "^27.0.2",
58
+ "tsx": "^4.21.0",
57
59
  "typescript": "5.9.3",
58
60
  "vite": "^7.3.1",
59
61
  "vitest": "^4.0.17",