github-url-detection 11.0.1 → 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.
- package/distribution/index.d.ts +54 -0
- package/distribution/index.js +9 -0
- package/package.json +1 -1
package/distribution/index.d.ts
CHANGED
|
@@ -396,8 +396,42 @@ export declare const isSingleCommit: (url?: URL | HTMLAnchorElement | Location)
|
|
|
396
396
|
* @example https://github.com/sindresorhus/refined-github/blob/master/.gitattributes
|
|
397
397
|
* @example https://github.com/sindresorhus/refined-github/blob/fix-narrow-diff/distribution/content.css
|
|
398
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
|
|
399
414
|
*/
|
|
400
415
|
export declare const isSingleFile: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
416
|
+
/**
|
|
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;
|
|
401
435
|
/** @example https://github.com/sindresorhus/refined-github/find/master */
|
|
402
436
|
export declare const isFileFinder: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
403
437
|
/**
|
|
@@ -420,6 +454,11 @@ export declare const isForkingRepo: (url?: URL | HTMLAnchorElement | Location) =
|
|
|
420
454
|
export declare const isSingleGist: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
421
455
|
/** @example https://gist.github.com/kidonng/0d16c7f17045f486751fad1b602204a0/revisions */
|
|
422
456
|
export declare const isGistRevision: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
457
|
+
/**
|
|
458
|
+
* @example https://gist.github.com/fregante/2205329b71218fa2c1d3
|
|
459
|
+
* @example https://gist.github.com/sindresorhus/0ea3c2845718a0a0f0beb579ff14f064
|
|
460
|
+
*/
|
|
461
|
+
export declare const isGistFile: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
423
462
|
/**
|
|
424
463
|
* @example https://github.com/trending
|
|
425
464
|
* @example https://github.com/trending/developers
|
|
@@ -510,6 +549,21 @@ export declare const hasCode: (url?: URL | HTMLAnchorElement | Location) => bool
|
|
|
510
549
|
* @example https://github.com/sindresorhus/refined-github/blob/master/.gitattributes
|
|
511
550
|
* @example https://github.com/sindresorhus/refined-github/blob/fix-narrow-diff/distribution/content.css
|
|
512
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
|
|
513
567
|
* @example https://github.com/sindresorhus/refined-github/blame/master/package.json
|
|
514
568
|
*/
|
|
515
569
|
export declare const isRepoGitObject: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
package/distribution/index.js
CHANGED
|
@@ -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,
|