You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have tried to keep the API design similar to std/path with only difference being the input for the functions are string | URL and functions will always return as an instance of URL object wherever possible.
Currently I have implemented basename, dirname, extname, join, normalize, parse, format, sep.
Only relative and resolve is pending.
You should be able to copy most if not all of the code from the posixX family of std/path. I would make sure to test edgecases though. Does implementing sep make any sense for URLs? What about format?
IMO, the only useful utilities would be xname, resolve, and maybe normalize. I'm not sure about parse. I think we should definitely NOT implement relative as we should be encouraging people to use the base URL class:
As for join, as far as I can tell, the only difference between join and resolve is whether the path has to be absolute or not. For URLs, the path has to be absolute, so I would recommend either changing the behavior of join to resolve (to keep the name) or potentially just not including join at all in favor of resolve.
You should be able to copy most if not all of the code from the posixX family of std/path. I would make sure to test edgecases though.
Yes, I am using posix functions from std/path.
Does implementing sep make any sense for URLs?
Here's something to say. I have implemented sep as a function that can break https://github.com/denoland/deno_std to [ "https://github.com", "denoland", "deno_std" ] and SEP is a const of value "/"
What about format?
format just takes Partial<ParsedPath> as input and joins them. parse parses the url into ParsedPath.
I think we should definitely NOT implement relative as we should be encouraging people to use the base URL class:
Agreed.
so I would recommend either changing the behavior of join to resolve (to keep the name) or potentially just not including join at all in favor of resolve.
How about resolve being an alias for join or vice-versa?
I really like the idea of this module, as I often use the posix path fns for this, but having these use the existing path modules (v0.198.0) introduces unnecessary overhead from the windows implementations.
Activity
lino-levan commentedon Aug 3, 2023
Good to know that my analysis was not completely off-base 😅
tr1ckydev commentedon Aug 7, 2023
<URL>.toString()allows itself to be used in std/path.index.ts
console output
kt3k commentedon Aug 8, 2023
@tr1ckydev If the platform is windows,
std/pathdoesn't work for urls.tr1ckydev commentedon Aug 8, 2023
Ahh, I see. Is
std/urlbeing currently worked upon or I can work on it and send a pr? ( I have already started working on it)kt3k commentedon Aug 8, 2023
I don't think anybody started working on it. Which APIs are you planning to implement? Could you share the API designs first?
tr1ckydev commentedon Aug 8, 2023
I have tried to keep the API design similar to std/path with only difference being the input for the functions are
string | URLand functions will always return as an instance of URL object wherever possible.Currently I have implemented
basename,dirname,extname,join,normalize,parse,format,sep.Only
relativeandresolveis pending.tr1ckydev commentedon Aug 8, 2023
relativehas been implemented but I am skeptical ifresolveshould be implemented in case of urls?Also, I have started writing the tests for the functions, and they are working very promising so far.
lino-levan commentedon Aug 8, 2023
You should be able to copy most if not all of the code from the
posixXfamily ofstd/path. I would make sure to test edgecases though. Does implementingsepmake any sense for URLs? What aboutformat?IMO, the only useful utilities would be
xname,resolve, and maybenormalize. I'm not sure aboutparse. I think we should definitely NOT implementrelativeas we should be encouraging people to use the baseURLclass:As for
join, as far as I can tell, the only difference betweenjoinandresolveis whether the path has to be absolute or not. For URLs, the path has to be absolute, so I would recommend either changing the behavior ofjointoresolve(to keep the name) or potentially just not includingjoinat all in favor ofresolve.tr1ckydev commentedon Aug 8, 2023
Yes, I am using posix functions from
std/path.Here's something to say. I have implemented
sepas a function that can breakhttps://github.com/denoland/deno_stdto[ "https://github.com", "denoland", "deno_std" ]andSEPis a const of value"/"formatjust takesPartial<ParsedPath>as input and joins them.parseparses the url intoParsedPath.Agreed.
How about
resolvebeing an alias forjoinor vice-versa?lino-levan commentedon Aug 8, 2023
Is there a usecase for this? I feel like we should be pretty conservative about what we include in std.
Again, see above.
Pretty strongly against this. I think
resolveis unclear enough already. I thinkjoinshould be fine.tr1ckydev commentedon Aug 8, 2023
Okay, I get it. Then they can be omitted.
Sounds great. I will be keeping join only then.
jollytoad commentedon Aug 21, 2023
I really like the idea of this module, as I often use the posix path fns for this, but having these use the existing path modules (v0.198.0) introduces unnecessary overhead from the windows implementations.
I've proposed a modification of the path modules structure that could alleviate this... https://github.com/denoland/deno_std/discussions/3553