Make 404 pages more useful#1558
Conversation
The solution was overly specific, so we changed it to work for all 404s. We ignore some paths that are never reachable (right now `tree` and `blob`). For now it also doesn't change `blob` to `commits` anymore.
- Fetch the correct URL (it used to skip `tree/blob` entirely) - Fetch from right to left to look nicer - Reduce used elements and drop extra copy - Use plain for loops instead of multiple functional loops and flatteners
It wouldn't return cached values
If not available on page
Because this way it matches the repo header
|
Nice work, thanks for continuing on my work 👍 |
| // If the resource exists in the default branch, link it | ||
| async function addDefaultBranchLink(bar) { | ||
| const parts = getCleanPathname().split('/'); | ||
| const [,,, branch] = parts; |
There was a problem hiding this comment.
I don't think we should use destructuring when it's more than one lone ,.
There was a problem hiding this comment.
|
This is incredible useful 🎉 I constantly end up on 404 pages and have to manually modify the URL. |
|
No worries @dertieran, thanks for starting this! |
|
Yay! 🔥 |
| } | ||
| if (i === parts.length - 1) { | ||
| // The last part of the URL is a known 404 | ||
| bar.append(' / ', getStrikeThrough(part)); |
|
Another one is #3515 Will ask i you want to see it on the default branch. It will include a link of https://github.com/sindresorhus/refined-github/issues/master Which puts in the search bar |
|
Excellent, I definitely didn't spend much time thinking about all the possible URLs. Can you open a joint issue for both? It should probably be limited to |


Examples:
404 file: https://github.com/sindresorhus/refined-github/blob/master/wrong-file
410 file: https://github.com/sindresorhus/refined-github/blob/master/extension/content.js
404 branch + file: https://github.com/sindresorhus/refined-github/blob/404/wrong-file
410 branch + file: https://github.com/sindresorhus/refined-github/blob/404/package.json
Closes #485
Replaces, includes and closes #1531
Depends on and includes #1557