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

Add utility to build GenericPaths from unencoded strings. #396

Closed

Conversation

vnayar
Copy link

@vnayar vnayar commented Mar 24, 2024

This utility function will be used to url-encode paths added to a URLRouter, which avoids the problem of having to resolve encoding problems when resolving routes.

See: vibe-d/vibe-http#34

This utility function will be used to url-encode paths added to a URLRouter, which
avoids the problem of having to resolve encoding problems when resolving routes.

See: vibe-d/vibe-http#34
@s-ludwig
Copy link
Member

Hm, the behavior of this function doesn't seem quite sound in the general case. The "unencoded string" is not able to represent all possible InetPath paths, but can represent more paths than are possible to represent with a WindowsPath. Offering a function like this seems very error prone, as the user would typically not have all edge-cases in mind when using it and the input string format is not clearly defined anywhere.

But, leaving the question of whether this should be a dedicated API aside, isn't this doing the same as cast(InetPath)PosixPath(str) when looking at the InetPath case?

@vnayar
Copy link
Author

vnayar commented Mar 24, 2024

But, leaving the question of whether this should be a dedicated API aside, isn't this doing the same as cast(InetPath)PosixPath(str) when looking at the InetPath case?

I'm still ramping up on this part of the code, not yet fully familiar with its patterns and intent. The approach of doing cast(InetPath)PosixPath(str) seems to do exactly what I was looking for. I'll see if I can use that instead in vibe-d/vibe-http#35 and thereby eliminate the need for this MR.

@vnayar
Copy link
Author

vnayar commented Mar 24, 2024

cast(InetPath)PosixPath(str) does exactly what's needed, this MR can be closed.

@vnayar vnayar closed this Mar 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants