Repository navigation
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.
Now that I'm looking at the tests, I'm not sure if join even makes sense.
There was a problem hiding this comment.
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 |
|
|
kt3k
left a comment
There was a problem hiding this comment.
@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