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

What is the point of directory, suffix, etc? #393

Open
vinniefalco opened this issue Jan 11, 2020 · 2 comments
Open

What is the point of directory, suffix, etc? #393

vinniefalco opened this issue Jan 11, 2020 · 2 comments
Labels

Comments

@vinniefalco
Copy link

Are things like directory() and suffix() really necessary? The RFC doesn't say much about this, and there are plenty of cases where "all but the last non-empty segment" is not actually the directory. For example: in /x/index.php/y/z, the directory is x, the file is index.php, and /y/z is an additional argument passed to the php script.

I note that Mozilla URL and Node.js URL don't offer these conveniences.

I ask, because I am modeling my C++ URL library after this one and I am hearing a lot of voices from self-professed experts that "these features are not necessary." So before I do a bunch of possibly unnecessary work, are there use cases for manipulating the directory? For replacing path segments in the middle (i.e. replace the middle path segment with these 3 new segments)? Do you have any links to projects that make heavy use of URI.js?

Thanks!

@rodneyrehm
Copy link
Member

Hey there,

sorry for the late reply - currently on the road…

Are things like directory() and suffix() really necessary?

I remember having had that discussion when the URL spec was written. It was decided that these utilities were not strictly necessary and therefore omitted completely.

URI.js is a collection of pretty much everything (or at least most things) you could do with an URL. That does not say that these features are really necessary. URL class shows what the standard settled on. For me that's been 99% sufficient. The rare cases of actually having had to mangle paths I resorted to node's path module.

I ask, because I am modeling my C++ URL library after this one

Is there a reason you're not going for parity with URL? That would be my choice in this day and age…

Do you have any links to projects that make heavy use of URI.js?

I do not. And I would not recommend using it since support (including polyfills) for URL has become wide spread.

@vinniefalco
Copy link
Author

Is there a reason you're not going for parity with URL?

Yes, well I liked your library better :) Because the documentation makes strong statements about the functionality and it looked more robust. But I did not have any evidence those features are strictly necessary, and some other people are pressuring me not to include them in my URL library (which is here (https://github.com/vinniefalco/url).

URL class shows what the standard settled on. For me that's been 99% sufficient.

Yes, given that I can't find any evidence of user need for things like directory and the others (which still seem thoughtful and nice), my second choice will be simply to copy the URL class specification which is straight forward enough, subject to the modifications necessary to adhere to "Modern C++."

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

No branches or pull requests

2 participants