Skip to content

Support partially URL-encoded paths#244

Draft
SunsetTechuila wants to merge 3 commits intomainfrom
decode
Draft

Support partially URL-encoded paths#244
SunsetTechuila wants to merge 3 commits intomainfrom
decode

Conversation

@SunsetTechuila
Copy link
Copy Markdown
Member

Closes #206

"name": "sandbox",
"nameWithOwner": "refined-github/sandbox",
"owner": "refined-github",
"path": "blob/bracket-in-path/foo%2F[bar]%2Fbaz",
Copy link
Copy Markdown
Member Author

@SunsetTechuila SunsetTechuila Apr 7, 2026

Choose a reason for hiding this comment

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

Even GitHub doesn't handle this correctly

Image

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It should show my commit: refined-github/sandbox@17041ac

@fregante
Copy link
Copy Markdown
Member

fregante commented Apr 7, 2026

One thing we should validate before going through with this is where we can find these URLs in the first place.

If there's a situation where GitHub generates encoded URLs, there's a non-zero chance that decoding it will break it.

@fregante
Copy link
Copy Markdown
Member

fregante commented Apr 7, 2026

In refined-github/refined-github#8358 I did something similar though

@SunsetTechuila
Copy link
Copy Markdown
Member Author

SunsetTechuila commented Apr 7, 2026

where we can find these URLs in the first place

?

expect(getRepositoryInfoAdapter('https://github.com/refined-github/sandbox/blob/bracket-in-path/foo%2F%5Bbar%5D%2Fbaz')).toMatchInlineSnapshot(`

expect(getRepositoryInfoAdapter('https://github.com/refined-github/sandbox/blob/bracket-in-path/foo%252F%5Bbar%5D%252Fbaz')).toMatchInlineSnapshot(`

expect(getRepositoryInfoAdapter('https://github.com/refined-github/sandbox/tree/%F0%9F%98%B1')).toMatchInlineSnapshot(`

@SunsetTechuila
Copy link
Copy Markdown
Member Author

decoding it will break it

break what exactly?

@fregante
Copy link
Copy Markdown
Member

fregante commented Apr 8, 2026

where we can find these URLs in the first place

?

expect(getRepositoryInfoAdapter('https://github.com/refined-github/sandbox/blob/bracket-in-path/foo%2F%5Bbar%5D%2Fbaz')).toMatchInlineSnapshot(`

expect(getRepositoryInfoAdapter('https://github.com/refined-github/sandbox/blob/bracket-in-path/foo%252F%5Bbar%5D%252Fbaz')).toMatchInlineSnapshot(`

expect(getRepositoryInfoAdapter('https://github.com/refined-github/sandbox/tree/%F0%9F%98%B1')).toMatchInlineSnapshot(`

Those URLs are made up. I mean where on GitHub can I find GitHub generating those URLs? We don't really have to support things that don't exist in the wild, this is what I mean. Is it only for files?

@fregante
Copy link
Copy Markdown
Member

fregante commented Apr 8, 2026

decoding it will break it

break what exactly?

What happens when you decode "folder/file-#1.md" and then re-compose the URL? Every feature that attempts to build a URL back from this will have to handle re-encoding manually.

If this helper is used locally this won't happen, but I think it's exported right?

I added some examples in the sandbox: https://github.com/refined-github/sandbox/tree/default-a/files

@fregante
Copy link
Copy Markdown
Member

fregante commented Apr 8, 2026

I think overall it makes sense, but we should check what this change means downstream, with features that are already handling decoding and others needing to properly generate URL from already-decoded parts

@SunsetTechuila
Copy link
Copy Markdown
Member Author

Those URLs are made up. I mean where on GitHub can I find GitHub generating those URLs

I don't understand. How they are "made up"? Your browser encode URLs, not GitHub. Just open those files

msedge_F3NBl8NhGy

@SunsetTechuila
Copy link
Copy Markdown
Member Author

Is it only for files?

Files and branches

@fregante
Copy link
Copy Markdown
Member

fregante commented Apr 8, 2026

How they are "made up"?

Can I click those links? We have a sandbox specifically to create REAL URLs.

I don't understand.

You know how we ask for "test URLs" for each issue, right? We want to click those URLs and find the issue. What I asked is a repro where I can find GitHub generating those URLs. As always: REAL, existing, found in GitHub's own DOM and not typed out in the URL bar.

Of course they exist. This exists too, but it's not found in GitHub's DOM so I'm not going to write code to handle a no parameter

https://github.com///?no=luck

@SunsetTechuila
Copy link
Copy Markdown
Member Author

SunsetTechuila commented Apr 8, 2026

Can I click those links?

Yes!

msedge_bNmcH9vA2v

@SunsetTechuila
Copy link
Copy Markdown
Member Author

SunsetTechuila commented Apr 8, 2026

GitHub's DOM

What does this have to do with the DOM? We use location in 95% of cases when we call getRepo. And location.pathname is always encoded

image image

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.

Support partially URL-encoded paths

2 participants