Refined-github: Master branch links are broken for branches with a `/` in the branch name

Created on 18 May 2019  路  7Comments  路  Source: sindresorhus/refined-github

Master branch links are broken for branches with a / in the branch name.

eg. branch sk/dev links to [repo]/tree/master/dev

bug is here: https://github.com/sindresorhus/refined-github/blob/master/source/features/branch-buttons.tsx#L78
and here: https://github.com/sindresorhus/refined-github/blob/master/source/libs/page-detect.ts#L84

bug good first issue help wanted

All 7 comments

Can you post a real link to a slashed/branch so I don't have to go hunting for one? 馃槄

https://github.com/simonkotwicz/refined-github/blob/branch/still-branch/.travis.yml#L6

Looks like the assumption of no / in branch names is in shortened links, permalinks and probably more places too.

  • master links can be fixed but it needs to get the branch name from the branch selector dropdown instead of just the URL
  • shortened URLs can't be fixed because we can't tell branch/file apart from branch/still-branch just by looking at the URL: https://github.com/bfred-it/shorten-repo-url/issues/9

    Can you ask GitHub to url-encode the branch name so we get a branch%2Fname in the URL?

right I guess the only other option would be change the format of the shortened URLs to be:

simonkotwicz/refined-github:branch/still-branch/.travis.yml#L6

What do you think about changing:

https://github.com/sindresorhus/refined-github/blob/master/source/features/branch-buttons.tsx#L78

TO

master/source/features/branch-buttons.tsx#L78

That way at least shortened URLs always work (display properly). Also, Github already uses @ specifically for commit hashes in links (I think the special branch formatting inside links is a little strange as well).

I think the special branch formatting inside links is a little strange as well

I don't: commits, branches, tags, are all just git references, so https://github.com/bfred-it/shorten-repo-url tries to treat them all the same.

simonkotwicz/refined-github:branch/still-branch/.travis.yml#L6 is still hard to parse compared to:

https://github.com/simonkotwicz/refined-github/blob/branch/still-branch/.travis.yml#L6

At most I'd try:

simonkotwicz/refined-github/branch/still-branch/.travis.yml#L6

PR welcome on https://github.com/bfred-it/shorten-repo-url for this change


If anyone wants to pick this up, (the fixable bug part) change this line to use the URL from the branch selector instead of location.pathname. This would fix the master button on https://github.com/simonkotwicz/refined-github/blob/branch/still-branch/.travis.yml#L6

@bfred-it I would love to help! Maybe I can find time doing it later today.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yakov116 picture yakov116  路  3Comments

alexanderadam picture alexanderadam  路  3Comments

hkdobrev picture hkdobrev  路  3Comments

mischah picture mischah  路  3Comments

Arcanemagus picture Arcanemagus  路  3Comments