-
Notifications
You must be signed in to change notification settings - Fork 629
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
feat(std): Add std/url
module.
#3527
Conversation
Utilities for working with URL paths.
import { assertEquals } from "../assert/mod.ts"; | ||
import * as url from "./mod.ts"; | ||
|
||
const TESTSUITE: [[string | URL, ...string[]], URL][] = [ | ||
[ | ||
["https://deno.land", "std", "assert", "mod.ts"], | ||
new URL("https://deno.land/std/assert/mod.ts"), | ||
], | ||
[ | ||
[new URL("https://deno.land"), "std", "assert", "mod.ts"], | ||
new URL("https://deno.land/std/assert/mod.ts"), | ||
], | ||
[ | ||
[new URL("https://deno.land//"), "/std/", "/assert/", "//mod.ts"], | ||
new URL("https://deno.land/std/assert/mod.ts"), | ||
], | ||
[["https://deno.land/"], new URL("https://deno.land/")], | ||
]; | ||
|
||
Deno.test("join", function () { | ||
for (const [[test_url, ...paths], expected] of TESTSUITE) { | ||
assertEquals(url.join(test_url, ...paths), expected); | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that I'm looking at the tests, I'm not sure if join even makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it so?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it handles edgecases around double /
so maybe it's still useful. Not entirely sure what the utility is. Thoughts @marvinhagemeister?
Should |
I'm trying to think of a usecase and can't come up with one off of the top of my head. I think a lot of these things can be done as a follow-up PR. So no pressure to get everything in right now! |
I have fixed couple of bugs and added new edge cases tests. Will be adding them later by today. |
There is |
https://github.com/tr1ckydev/pathurl |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tr1ckydev LGTM. Nice work!
Agree, but as it's from url module so it can be expected. Even though dirname from path module returns parent path so works in case of url too imo. |
Thank you. I have also send another pull request which bug fixes many functions. |
Utilities for working with URL paths (#3515).
closes #3515