github-url-detection 11.0.1 → 11.1.1
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.
- package/distribution/index.d.ts +58 -0
- package/distribution/index.js +10 -1
- package/package.json +1 -1
package/distribution/index.d.ts
CHANGED
|
@@ -32,6 +32,8 @@ export declare const isRepoCommitList: (url?: URL | HTMLAnchorElement | Location
|
|
|
32
32
|
* @example https://github.com/sindresorhus/refined-github/compare/master...branch-name?quick_pull=1
|
|
33
33
|
* @example https://github.com/sindresorhus/refined-github/compare/branch-1...branch-2?quick_pull=1
|
|
34
34
|
* @example https://github.com/sindresorhus/refined-github/compare/test-branch?quick_pull=1
|
|
35
|
+
* @example https://github.com/refined-github/sandbox/compare/fregante-patch-2?expand=1
|
|
36
|
+
* @example https://github.com/refined-github/sandbox/compare/default-a...fregante-patch-2?expand=1
|
|
35
37
|
*/
|
|
36
38
|
export declare const isCompare: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
37
39
|
/**
|
|
@@ -212,6 +214,8 @@ export declare const isPRFiles: (url?: URL | HTMLAnchorElement | Location) => bo
|
|
|
212
214
|
* @example https://github.com/sindresorhus/refined-github/compare/master...branch-name?quick_pull=1
|
|
213
215
|
* @example https://github.com/sindresorhus/refined-github/compare/branch-1...branch-2?quick_pull=1
|
|
214
216
|
* @example https://github.com/sindresorhus/refined-github/compare/test-branch?quick_pull=1
|
|
217
|
+
* @example https://github.com/refined-github/sandbox/compare/fregante-patch-2?expand=1
|
|
218
|
+
* @example https://github.com/refined-github/sandbox/compare/default-a...fregante-patch-2?expand=1
|
|
215
219
|
*/
|
|
216
220
|
export declare const isQuickPR: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
217
221
|
export declare const isMergedPR: () => boolean;
|
|
@@ -396,8 +400,42 @@ export declare const isSingleCommit: (url?: URL | HTMLAnchorElement | Location)
|
|
|
396
400
|
* @example https://github.com/sindresorhus/refined-github/blob/master/.gitattributes
|
|
397
401
|
* @example https://github.com/sindresorhus/refined-github/blob/fix-narrow-diff/distribution/content.css
|
|
398
402
|
* @example https://github.com/sindresorhus/refined-github/blob/master/edit.txt
|
|
403
|
+
* @example https://github.com/sindresorhus/refined-github/blob/master/readme.md
|
|
404
|
+
* @example https://github.com/sindresorhus/refined-github/blob/master/README.markdown
|
|
405
|
+
* @example https://github.com/sindresorhus/refined-github/blob/main/docs/guide.mdown
|
|
406
|
+
* @example https://github.com/sindresorhus/refined-github/blob/main/CONTRIBUTING.mkdn
|
|
407
|
+
* @example https://github.com/sindresorhus/refined-github/blob/master/file.textile
|
|
408
|
+
* @example https://github.com/sindresorhus/refined-github/blob/master/file.rdoc
|
|
409
|
+
* @example https://github.com/sindresorhus/refined-github/blob/master/file.org
|
|
410
|
+
* @example https://github.com/sindresorhus/refined-github/blob/master/file.creole
|
|
411
|
+
* @example https://github.com/sindresorhus/refined-github/blob/master/file.mediawiki
|
|
412
|
+
* @example https://github.com/sindresorhus/refined-github/blob/master/file.wiki
|
|
413
|
+
* @example https://github.com/sindresorhus/refined-github/blob/master/file.rst
|
|
414
|
+
* @example https://github.com/sindresorhus/refined-github/blob/master/file.asciidoc
|
|
415
|
+
* @example https://github.com/sindresorhus/refined-github/blob/master/file.adoc
|
|
416
|
+
* @example https://github.com/sindresorhus/refined-github/blob/master/file.asc
|
|
417
|
+
* @example https://github.com/sindresorhus/refined-github/blob/master/file.pod
|
|
399
418
|
*/
|
|
400
419
|
export declare const isSingleFile: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
420
|
+
/**
|
|
421
|
+
* @example https://github.com/sindresorhus/refined-github/blob/master/readme.md
|
|
422
|
+
* @example https://github.com/sindresorhus/refined-github/blob/master/README.markdown
|
|
423
|
+
* @example https://github.com/sindresorhus/refined-github/blob/main/docs/guide.mdown
|
|
424
|
+
* @example https://github.com/sindresorhus/refined-github/blob/main/CONTRIBUTING.mkdn
|
|
425
|
+
* @example https://github.com/sindresorhus/refined-github/blob/master/file.textile
|
|
426
|
+
* @example https://github.com/sindresorhus/refined-github/blob/master/file.rdoc
|
|
427
|
+
* @example https://github.com/sindresorhus/refined-github/blob/master/file.org
|
|
428
|
+
* @example https://github.com/sindresorhus/refined-github/blob/master/file.creole
|
|
429
|
+
* @example https://github.com/sindresorhus/refined-github/blob/master/file.mediawiki
|
|
430
|
+
* @example https://github.com/sindresorhus/refined-github/blob/master/file.wiki
|
|
431
|
+
* @example https://github.com/sindresorhus/refined-github/blob/master/file.rst
|
|
432
|
+
* @example https://github.com/sindresorhus/refined-github/blob/master/file.asciidoc
|
|
433
|
+
* @example https://github.com/sindresorhus/refined-github/blob/master/file.adoc
|
|
434
|
+
* @example https://github.com/sindresorhus/refined-github/blob/master/file.asc
|
|
435
|
+
* @example https://github.com/sindresorhus/refined-github/blob/master/file.pod
|
|
436
|
+
*/
|
|
437
|
+
export declare const isRenderedTextFile: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
438
|
+
export declare const hasRenderedText: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
401
439
|
/** @example https://github.com/sindresorhus/refined-github/find/master */
|
|
402
440
|
export declare const isFileFinder: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
403
441
|
/**
|
|
@@ -420,6 +458,11 @@ export declare const isForkingRepo: (url?: URL | HTMLAnchorElement | Location) =
|
|
|
420
458
|
export declare const isSingleGist: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
421
459
|
/** @example https://gist.github.com/kidonng/0d16c7f17045f486751fad1b602204a0/revisions */
|
|
422
460
|
export declare const isGistRevision: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
461
|
+
/**
|
|
462
|
+
* @example https://gist.github.com/fregante/2205329b71218fa2c1d3
|
|
463
|
+
* @example https://gist.github.com/sindresorhus/0ea3c2845718a0a0f0beb579ff14f064
|
|
464
|
+
*/
|
|
465
|
+
export declare const isGistFile: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
423
466
|
/**
|
|
424
467
|
* @example https://github.com/trending
|
|
425
468
|
* @example https://github.com/trending/developers
|
|
@@ -510,6 +553,21 @@ export declare const hasCode: (url?: URL | HTMLAnchorElement | Location) => bool
|
|
|
510
553
|
* @example https://github.com/sindresorhus/refined-github/blob/master/.gitattributes
|
|
511
554
|
* @example https://github.com/sindresorhus/refined-github/blob/fix-narrow-diff/distribution/content.css
|
|
512
555
|
* @example https://github.com/sindresorhus/refined-github/blob/master/edit.txt
|
|
556
|
+
* @example https://github.com/sindresorhus/refined-github/blob/master/readme.md
|
|
557
|
+
* @example https://github.com/sindresorhus/refined-github/blob/master/README.markdown
|
|
558
|
+
* @example https://github.com/sindresorhus/refined-github/blob/main/docs/guide.mdown
|
|
559
|
+
* @example https://github.com/sindresorhus/refined-github/blob/main/CONTRIBUTING.mkdn
|
|
560
|
+
* @example https://github.com/sindresorhus/refined-github/blob/master/file.textile
|
|
561
|
+
* @example https://github.com/sindresorhus/refined-github/blob/master/file.rdoc
|
|
562
|
+
* @example https://github.com/sindresorhus/refined-github/blob/master/file.org
|
|
563
|
+
* @example https://github.com/sindresorhus/refined-github/blob/master/file.creole
|
|
564
|
+
* @example https://github.com/sindresorhus/refined-github/blob/master/file.mediawiki
|
|
565
|
+
* @example https://github.com/sindresorhus/refined-github/blob/master/file.wiki
|
|
566
|
+
* @example https://github.com/sindresorhus/refined-github/blob/master/file.rst
|
|
567
|
+
* @example https://github.com/sindresorhus/refined-github/blob/master/file.asciidoc
|
|
568
|
+
* @example https://github.com/sindresorhus/refined-github/blob/master/file.adoc
|
|
569
|
+
* @example https://github.com/sindresorhus/refined-github/blob/master/file.asc
|
|
570
|
+
* @example https://github.com/sindresorhus/refined-github/blob/master/file.pod
|
|
513
571
|
* @example https://github.com/sindresorhus/refined-github/blame/master/package.json
|
|
514
572
|
*/
|
|
515
573
|
export declare const isRepoGitObject: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
package/distribution/index.js
CHANGED
|
@@ -47,7 +47,7 @@ var isPRFile404 = () => isPRFiles() && document.title.startsWith("Commit range n
|
|
|
47
47
|
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|(changes(\/[\da-f]{7,40}..[\da-f]{7,40})?$))/.test(getRepo(url)?.path) || isPRCommit(url);
|
|
50
|
-
var isQuickPR = (url = location) => isCompare(url) && /[?&]quick_pull=1(&|$)/.test(url.search);
|
|
50
|
+
var isQuickPR = (url = location) => isCompare(url) && /[?&](quick_pull|expand)=1(&|$)/.test(url.search);
|
|
51
51
|
var getStateLabel = () => $([
|
|
52
52
|
".State",
|
|
53
53
|
// Old view
|
|
@@ -142,6 +142,8 @@ var isRepoTree = (url = location) => _isRepoRoot(url) || Boolean(getRepo(url)?.p
|
|
|
142
142
|
var isRepoWiki = (url = location) => Boolean(getRepo(url)?.path.startsWith("wiki"));
|
|
143
143
|
var isSingleCommit = (url = location) => /^commit\/[\da-f]{5,40}$/.test(getRepo(url)?.path);
|
|
144
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);
|
|
145
147
|
var isFileFinder = (url = location) => Boolean(getRepo(url)?.path.startsWith("find/"));
|
|
146
148
|
var isRepoFile404 = (url = location) => (isSingleFile(url) || isRepoTree(url)) && document.title.startsWith("File not found");
|
|
147
149
|
var isRepoForksList = (url = location) => getRepo(url)?.path === "network/members";
|
|
@@ -150,6 +152,10 @@ var isForkedRepo = () => exists('meta[name="octolytics-dimension-repository_is_f
|
|
|
150
152
|
var isForkingRepo = (url = location) => getRepo(url)?.path === "fork";
|
|
151
153
|
var isSingleGist = (url = location) => /^[^/]+\/[\da-f]{20,32}(\/[\da-f]{40})?$/.test(getCleanGistPathname(url));
|
|
152
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
|
+
};
|
|
153
159
|
var isTrending = (url = location) => url.pathname === "/trending" || url.pathname.startsWith("/trending/");
|
|
154
160
|
var isBranches = (url = location) => Boolean(getRepo(url)?.path.startsWith("branches"));
|
|
155
161
|
var doesLookLikeAProfile = (string) => typeof string === "string" && string.length > 0 && !string.includes("/") && !string.includes(".") && !reservedNames.includes(string);
|
|
@@ -234,6 +240,7 @@ export {
|
|
|
234
240
|
hasFileEditor,
|
|
235
241
|
hasFiles,
|
|
236
242
|
hasReleaseEditor,
|
|
243
|
+
hasRenderedText,
|
|
237
244
|
hasRepoHeader,
|
|
238
245
|
hasRichTextEditor,
|
|
239
246
|
hasWikiPageEditor,
|
|
@@ -266,6 +273,7 @@ export {
|
|
|
266
273
|
isForkedRepo,
|
|
267
274
|
isForkingRepo,
|
|
268
275
|
isGist,
|
|
276
|
+
isGistFile,
|
|
269
277
|
isGistProfile,
|
|
270
278
|
isGistRevision,
|
|
271
279
|
isGlobalIssueOrPRList,
|
|
@@ -311,6 +319,7 @@ export {
|
|
|
311
319
|
isQuickPR,
|
|
312
320
|
isReleases,
|
|
313
321
|
isReleasesOrTags,
|
|
322
|
+
isRenderedTextFile,
|
|
314
323
|
isRepliesSettings,
|
|
315
324
|
isRepo,
|
|
316
325
|
isRepoCommitList,
|