Skip to content

Conversation

@fregante
Copy link
Member

@fregante fregante commented Oct 3, 2018

dertieran and others added 15 commits September 15, 2018 22:23
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
Because this way it matches the repo header
@fregante
Copy link
Member Author

fregante commented Oct 3, 2018

screen shot 2018-10-03 at 17 39 35

@dertieran
Copy link
Contributor

Nice work, thanks for continuing on my work 👍
(Sorry for my PRs going stall, it's been a few busy weeks 😅)

// If the resource exists in the default branch, link it
async function addDefaultBranchLink(bar) {
const parts = getCleanPathname().split('/');
const [,,, branch] = parts;
Copy link
Member

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 ,.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sindresorhus
Copy link
Member

This is incredible useful 🎉 I constantly end up on 404 pages and have to manually modify the URL.

@fregante
Copy link
Member Author

fregante commented Oct 4, 2018

No worries @dertieran, thanks for starting this!

@sindresorhus sindresorhus changed the title Useful 404 pages Make 404 pages more useful Oct 4, 2018
@sindresorhus sindresorhus merged commit 0903681 into refined-github:master Oct 4, 2018
@sindresorhus
Copy link
Member

Yay! 🔥

}
if (i === parts.length - 1) {
// The last part of the URL is a known 404
bar.append(' / ', getStrikeThrough(part));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nitpick if the user is not found then the slash is appended.
Is that intended?

image

@yakov116
Copy link
Member

yakov116 commented Oct 4, 2018

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 is:open is:issue author:master

@fregante fregante deleted the useful-404 branch October 5, 2018 00:15
@fregante
Copy link
Member Author

fregante commented Oct 5, 2018

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 tree and blob URLs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Make 404 pages more useful

4 participants