-
Notifications
You must be signed in to change notification settings - Fork 43
-
Notifications
You must be signed in to change notification settings - Fork 43
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
Filter out undefined/null #18
Comments
Few other cases, which produces wrong results: urljoin(undefined, 'test')
// -> /test, should be test
urljoin('', 'test')
// -> /test, should be test
urljoin(undefined, '/test')
// -> //test, should be test
urljoin('', '/test')
// -> //test, should be test |
Wait. I think it would be more appropriate to throw on |
I just published v4.0.0, the new behavior will throw an exception like |
Hello @jfromaniello , I come to confirm your last comment on #36
The change on
Broke all my end-point constructions where a numeric
I saw that |
Reading the original issue again, I'm starting to think this change should be reverted/fixed: maybe we can safely use old behavior on any component that has a Another concern I have is that the objective of the library should be to compose proper urls, so things like...
... throw because don't look like URLs? Also, the original issue cares about a thing we should not care: a trailing slash. When it comes to URLs, a trailing slash is a good thing, in fact, not having a trailing slash is bad So does it matter if my URLs include a trailing slash?:
Haven't seen Finally, this cannot be taken as a rule, but I tried a few sites that use extensions like http://some.site.com/some/article.html and it works perfectly with trailing slash. So I think we should consider which case produces the lesser evil. |
I think we can allow numbers, I am not sure about other things, it might get confusing. with regards to the trailing slash the problem was the unintended consequence.. the very first example in this issue is:
I don't think the user in this case actually want a trailing slash, the problem was that this library was failing silently. Let's consider a case where the user want to append something to the url and also wants a trailing slash regardless if is the argument segment is null or not. with the previous behavior you have to do something like this:
as you can see in the first example there is a double slash at the end. with v4 you can do something like this and get the expected result:
I'd like this library to follow POLA (principle of least astonishment). Regarding the CHANGELOG I think it states clearly here:
|
Alternative to close jfromaniello#18. Also add tests for missing unaccepted Javascript primitive data types.
I just made a PR for your consideration. It reinstates numbers as a possible parameter and its test. Also adds some missing primitive data type tests in accordance with your comment:
So we allow strings and numbers and nothing else. Regarding A possible solution would be to edit it before committing, adding necessary clarifications, because while it clearly states the changes done, it's hard for a person skimming through it to see if it's safe to make an upgrade. To emphasize this I'll describe my current situation: I'm upgrading all dependencies on six months old project, so I have many changes. My workflow is like this:
As you could perceive, it's pretty exhausting and big text plus the explicit phrase: "breaking changes" helps a lot to make this faster. |
The following should be equivelant:
Note the trailing slash.
The text was updated successfully, but these errors were encountered: