-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Make 404 pages more useful #1558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should use destructuring when it's more than one lone ,.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
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)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
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