Skip to content
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

Move to WHATWG URL API #7

Open
Zauberbutter opened this issue Apr 23, 2021 · 5 comments
Open

Move to WHATWG URL API #7

Zauberbutter opened this issue Apr 23, 2021 · 5 comments

Comments

@Zauberbutter
Copy link
Contributor

This package uses the deprecated legacy URL API, so I tried to make it work with the new WHATWG URL API. But that's not possible due to the new path encoding becomes %E2%80%A6 when formatting the URL. Maybe we need to manually format the URL or insert ... instead.

@sindresorhus
Copy link
Owner

Can't we just replace %E2%80%A6 with that character after using URL?

@Zauberbutter
Copy link
Contributor Author

@sindresorhus What if the original URL already has this included?

@sindresorhus
Copy link
Owner

Hm. We could use decodeURIComponent on the final URL. It's going to be used for presentational purposes, so it doesn't have to be a valid URL. Although, I haven't fully thought through all the consequences of this.

@Zauberbutter
Copy link
Contributor Author

In my use case I want to use the truncated URL for a linkchecker dashboard and that wouldn't work well with the decodeURIComponent solution.
Let's say the original (broken) URL is https://www.example.com/some/dir/file%20with%20spaces.html and the truncated URL that the dashboard shows is then https://www.example.com/…/file with spaces.html. Now if you CTRLF in your code for file with spaces.html you can't find it.

Maybe we could insert an unique string and replace it with afterwards?

@sindresorhus
Copy link
Owner

Maybe we could insert an unique string and replace it with … afterwards?

Yeah, that could work.

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

No branches or pull requests

2 participants