Node: src: add node::url::URL::href() method

Created on 31 Aug 2018  Â·  19Comments  Â·  Source: nodejs/node

Is your feature request related to a problem? Please describe.
I need to get href based on instance of URL object in native code.

Describe the solution you'd like
I can use href() method that is added in addition to existing getters.

feature request help wanted whatwg-url

Most helpful comment

I'm taking over this issue

All 19 comments

@nodejs/url

the url serializer is written in js, so i'm not 100% sure if this is possible without a lot of code duplication

@devsnek Yeah my guess is that we will have to duplicate. That's fine though, as we already have a duplicated URL class in C++ anyway.

Are there any specs for URL::href()?

I am not sure if is this one
https://url.spec.whatwg.org/#dom-url-href

@tigercosmos Yes! You can even look at how lib/internal/url.js implements it in JavaScript, and just duplicate that logic in C++.

Hi @ak239
I think you can use toString() also?
They both return the same result.

I'm taking over this issue

@stropitek As @WaleedAshraf commented, this might not be necessary since ToString() also works… just as a heads up, so you don’t do unnecessary work :)

May be worth it to dig deeper to verify if ToString() actually exists and works in C++.

If it does to remove this TODO and update to use the ToString() function.
https://github.com/ak239/node/blob/master/src/inspector_agent.cc#L622

No the ToString method exists on URLHost class not on the URL class.

Is this being actively worked on?

@ak239 This is still something you want/need? Or did you find some other workaround?

@Trott
@addaleax and I looked into this on Code + Learn. ToString() method can serve the purpose. I think this can be closed.

There is no URL::ToString method and AFAIK @stropitek has a wip branch to add it

Yup. That's URLHost not URL. We were confused.

There is no URL::ToString method and AFAIK @stropitek has a wip branch to add it

Would it make sense to open a WIP PR?

This seems like it stalled. I don't know if @ak239 still needs this after all this time and I don't know that anyone else is asking for it. I'd be inclined to close it unless @ak239 or someone else indicates it is still a desirable feature for them and/or someone opens a PR.

As far as I remember the motivation behind this one was driven by one of the comments in the code review for one of my PRs: https://github.com/nodejs/node/pull/22251#discussion_r214210773
It looks like there were no other requests for href getter over the last year and a half so I will close this one. Feel free to reopen it if you think that we need href getter.

Was this page helpful?
0 / 5 - 0 ratings