Skip to content

isRepoRoot doesn't work on branches with slashes #15

@fregante

Description

@fregante

I think I found a way to determine isRepoRoot: use the title

/fregante/github-url-detection fregante/github-url-detection: Which GitHub page are you on? Is it an issue? Is it a list? Perfect for your WebExtension or userscript
/fregante/github-url-detection/tree/npm-test fregante/github-url-detection at npm-test
/fregante/github-url-detection/tree/npm-test/esm github-url-detection/esm at npm-test · fregante/github-url-detection

You can see 2 behaviors:

  • isRepoRoot starts with getRepoURL
  • isRepoTree does not (but ends with getRepoURL)
    • warning: if the repo is called fregante/fregante and the folder is fregante, then title starts with fregante/fregante and ends with fregante/fregante

The code might be:

const isRepoRoot = (url) => /^(tree\/[^/]+)?$/.test(getRepoPath(url)!) || (!url && document.title.startsWith(getRepoURL()) && !document.title.endsWith(getRepoURL()))

Originally discussed at refined-github/refined-github#3254 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions