diff --git a/index.ts b/index.ts index fe4450b..e67adc3 100644 --- a/index.ts +++ b/index.ts @@ -61,17 +61,19 @@ TEST: addTests('isCompareWikiPage', [ 'https://github.com/brookhong/Surfingkeys/wiki/Color-Themes/_compare/8ebb46b1a12d16fc1af442b7df0ca13ca3bb34dc...80e51eeabe69b15a3f23880ecc36f800b71e6c6d', ]); +/** + * @deprecated Use `isHome` and/or `isFeed` instead + */ export const isDashboard = (url: URL | HTMLAnchorElement | Location = location): boolean => !isGist(url) && /^$|^(orgs\/[^/]+\/)?dashboard(-feed)?(\/|$)/.test(getCleanPathname(url)); TEST: addTests('isDashboard', [ 'https://github.com///', 'https://github.com//', 'https://github.com/', 'https://github.com', - 'https://github.com/orgs/test/dashboard', + 'https://github.com/orgs/refined-github/dashboard', 'https://github.com/dashboard/index/2', 'https://github.com//dashboard', 'https://github.com/dashboard', - 'https://github.com/orgs/edit/dashboard', 'https://github.big-corp.com/', 'https://not-github.com/', 'https://my-little-hub.com/', @@ -84,6 +86,31 @@ TEST: addTests('isDashboard', [ 'https://github.com/dashboard-feed', ]); +export const isHome = (url: URL | HTMLAnchorElement | Location = location): boolean => !isGist(url) && /^$|^dashboard\/?$/.test(getCleanPathname(url)); +TEST: addTests('isHome', [ + 'https://github.com', + 'https://github.com//dashboard', + 'https://github.com///', + 'https://github.com//', + 'https://github.com/', + 'https://github.com/dashboard', + 'https://github.big-corp.com/', + 'https://not-github.com/', + 'https://my-little-hub.com/', + 'https://github.com/?tab=repositories', // Gotcha for `isUserProfileRepoTab` + 'https://github.com/?tab=stars', // Gotcha for `isUserProfileStarsTab` + 'https://github.com/?tab=followers', // Gotcha for `isUserProfileFollowersTab` + 'https://github.com/?tab=following', // Gotcha for `isUserProfileFollowingTab` + 'https://github.com/?tab=overview', // Gotcha for `isUserProfileMainTab` + 'https://github.com?search=1', // Gotcha for `isRepoTree` +]); + +export const isFeed = (url: URL | HTMLAnchorElement | Location = location): boolean => !isGist(url) && /^(feed|orgs\/[^/]+\/dashboard)\/?$/.test(getCleanPathname(url)); +TEST: addTests('isFeed', [ + 'https://github.com/feed', + 'https://github.com/orgs/refined-github/dashboard', +]); + export const isEnterprise = (url: URL | HTMLAnchorElement | Location = location): boolean => url.hostname !== 'github.com' && url.hostname !== 'gist.github.com'; TEST: addTests('isEnterprise', [ 'https://github.big-corp.com/', diff --git a/package-lock.json b/package-lock.json index 7865742..a0146a6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "11.1.2", "license": "MIT", "dependencies": { - "github-reserved-names": "^2.1.1" + "github-reserved-names": "^2.1.2" }, "devDependencies": { "@sindresorhus/tsconfig": "^8.1.0", @@ -820,19 +820,6 @@ "node": ">=6.0.0" } }, - "node_modules/@jridgewell/source-map": { - "version": "0.3.11", - "resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.11.tgz", - "integrity": "sha512-ZMp1V8ZFcPG5dIWnQLr3NSI1MiCU7UETdS/A0G8V/XWHvJv3ZsFqutJn1Y5RPmAPX6F3BiE397OqveU/9NCuIA==", - "dev": true, - "license": "MIT", - "optional": true, - "peer": true, - "dependencies": { - "@jridgewell/gen-mapping": "^0.3.5", - "@jridgewell/trace-mapping": "^0.3.25" - } - }, "node_modules/@jridgewell/sourcemap-codec": { "version": "1.5.5", "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", @@ -2496,15 +2483,6 @@ "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" } }, - "node_modules/buffer-from": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", - "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", - "dev": true, - "license": "MIT", - "optional": true, - "peer": true - }, "node_modules/builtin-modules": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-5.0.0.tgz", @@ -2719,15 +2697,6 @@ "dev": true, "license": "MIT" }, - "node_modules/commander": { - "version": "2.20.3", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", - "dev": true, - "license": "MIT", - "optional": true, - "peer": true - }, "node_modules/comment-parser": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.4.1.tgz", @@ -4982,9 +4951,9 @@ } }, "node_modules/github-reserved-names": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/github-reserved-names/-/github-reserved-names-2.1.1.tgz", - "integrity": "sha512-p8eMxZksQzh/z1awZz7NniSODL2QphpmpKNfGqPiN+BA/YjUaNtHkZoxK+kk/GP6go4imM1jprU0JAQG4tJ2mg==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/github-reserved-names/-/github-reserved-names-2.1.2.tgz", + "integrity": "sha512-vW5VYxCXbJ5VmMyy+LMGHVrLWx3g+uUaqKvUydPcbny4SS+0+hgtRysnP4f9DhtOB/ObFIdAo8Hn0z9/u1OKXg==", "license": "MIT" }, "node_modules/glob-parent": { @@ -7489,18 +7458,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true, - "license": "BSD-3-Clause", - "optional": true, - "peer": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/source-map-js": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", @@ -7511,19 +7468,6 @@ "node": ">=0.10.0" } }, - "node_modules/source-map-support": { - "version": "0.5.21", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", - "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", - "dev": true, - "license": "MIT", - "optional": true, - "peer": true, - "dependencies": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" - } - }, "node_modules/spdx-correct": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.2.0.tgz", @@ -7944,27 +7888,6 @@ "url": "https://opencollective.com/synckit" } }, - "node_modules/terser": { - "version": "5.44.1", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.44.1.tgz", - "integrity": "sha512-t/R3R/n0MSwnnazuPpPNVO60LX0SKL45pyl9YlvxIdkH0Of7D5qM2EVe+yASRIlY5pZ73nclYJfNANGWPwFDZw==", - "dev": true, - "license": "BSD-2-Clause", - "optional": true, - "peer": true, - "dependencies": { - "@jridgewell/source-map": "^0.3.3", - "acorn": "^8.15.0", - "commander": "^2.20.0", - "source-map-support": "~0.5.20" - }, - "bin": { - "terser": "bin/terser" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/tinybench": { "version": "2.9.0", "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz", diff --git a/package.json b/package.json index e0a23f5..97e0a4b 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "xo": "xo" }, "dependencies": { - "github-reserved-names": "^2.1.1" + "github-reserved-names": "^2.1.2" }, "devDependencies": { "@sindresorhus/tsconfig": "^8.1.0",