github-url-detection 7.0.0 → 7.0.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.
@@ -305,13 +305,13 @@ const isNewWikiPage = (url = location) => isRepoWiki(url) && getCleanPathname(ur
305
305
  const isNotifications = (url = location) => getCleanPathname(url) === "notifications";
306
306
  const isOrganizationProfile = () => exists('meta[name="hovercard-subject-tag"][content^="organization"]');
307
307
  const isOrganizationRepo = () => Boolean(document.querySelector("[data-owner-scoped-search-url]")?.dataset["ownerScopedSearchUrl"].startsWith("/org"));
308
- const isTeamDiscussion = (url = location) => /^orgs\/[^/]+\/teams\/[^/]+($|\/discussions)/.test(getCleanPathname(url));
308
+ const isTeamDiscussion = (url = location) => Boolean(getOrg(url)?.path.startsWith("teams"));
309
309
  const isOwnUserProfile = () => getCleanPathname() === getUsername();
310
310
  const isOwnOrganizationProfile = () => isOrganizationProfile() && !exists('[href*="contact/report-abuse?report="]');
311
311
  const isProject = (url = location) => /^projects\/\d+/.test(getRepo(url)?.path);
312
312
  const isProjects = (url = location) => getRepo(url)?.path === "projects";
313
- const isDiscussion = (url = location) => /^discussions\/\d+/.test(getRepo(url)?.path);
314
- const isDiscussionList = (url = location) => getRepo(url)?.path === "discussions";
313
+ const isDiscussion = (url = location) => /^discussions\/\d+/.test(getRepo(url)?.path ?? getOrg(url)?.path);
314
+ const isDiscussionList = (url = location) => getRepo(url)?.path === "discussions" || getOrg(url)?.path === "discussions";
315
315
  const isPR = (url = location) => /^pull\/\d+/.test(getRepo(url)?.path) && !isPRConflicts(url);
316
316
  const isPRConflicts = (url = location) => /^pull\/\d+\/conflicts/.test(getRepo(url)?.path);
317
317
  const isPRList = (url = location) => url.pathname === "/pulls" || getRepo(url)?.path === "pulls";
@@ -413,6 +413,13 @@ const getCleanGistPathname = (url = location) => {
413
413
  const [gist, ...parts] = pathname.split("/");
414
414
  return gist === "gist" ? parts.join("/") : void 0;
415
415
  };
416
+ const getOrg = (url = location) => {
417
+ const [, orgs, name, ...path] = url.pathname.split("/");
418
+ if (orgs === "orgs" && name) {
419
+ return { name, path: path.join("/") };
420
+ }
421
+ return void 0;
422
+ };
416
423
  const getRepo = (url) => {
417
424
  if (!url) {
418
425
  const canonical = document.querySelector('[property="og:url"]');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "github-url-detection",
3
- "version": "7.0.0",
3
+ "version": "7.0.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",