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

Only apply trailing slash utilities to supported protocols #189

Open
pi0 opened this issue Nov 15, 2023 · 3 comments
Open

Only apply trailing slash utilities to supported protocols #189

pi0 opened this issue Nov 15, 2023 · 3 comments
Labels
discussion enhancement New feature or request

Comments

@pi0
Copy link
Member

pi0 commented Nov 15, 2023

Extracted from #175

Utilities for trailing slash (withTrailingSlash) operate on URIs that have a meaning for trailing slash. http, https, (perhaps rsync, ftp and custom protocols are included)

However there are protocols like data:, mailto:, blob:, etc do not expect a trailing slash to be added or removed from the end.

Having a check (for invalid or invalid list of protocols) is costly on runtime and also not maintainable. One solution would be to support new options to both opt-in and also configure the list which is against costly.

I am mainly thinking of differentiating based on proto: and proto:/ proto:// to do this automatically. (it still needs a new option to opt out btw)

@pi0 pi0 added enhancement New feature or request discussion labels Nov 15, 2023
@pi0 pi0 changed the title Only apply trailing slash utilities to http protocols Only apply trailing slash utilities to supported protocols Nov 15, 2023
@divine
Copy link
Contributor

divine commented Nov 15, 2023

Hello,

We discussed protocols before in #70. Summary there is a list of known protocols https://en.m.wikipedia.org/wiki/List_of_URI_schemes and an IANA list here https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml

Probably I could take care of it next week, hopefully but before would like to make tests with %100 coverage 😄

Thanks!

@pi0
Copy link
Member Author

pi0 commented Nov 15, 2023

Thanks for the links dear @divine. I am thinking of a strategy that does not requires a maintainable list btw as we need to keep ufo compact. But finally if no other ways, behind a flag we might use a compiled regex.

@manniL
Copy link
Member

manniL commented Nov 15, 2023

I am mainly thinking of differentiating based on proto: and proto:/ proto:// to do this automatically. (it still needs a new option to opt out btw)

Might break for some, e.g.:

  • aaa:// -> no trailing slash ever
  • facetime:// -> no trailing slash ever
  • cvs:// -> no trailing slash after ; (if ; is set)
  • dict:// -> no trailing slash at the end ever
  • gizmoproject:// -> no trailing slash ever

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants