-
Notifications
You must be signed in to change notification settings - Fork 917
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
[Chore] Update deprecated url methods (url.parse()
, url.format()
)
#1561
Comments
@joshuarrrr I will take this issue, and may raise a PR about it later. |
@wanglam can you add You can search for all imports from the |
@ashwin-pc Sure, the |
According to my research and testing, using whatwg URL cannot completely replace the use cases of node url related methods. They mainly have the following differences:
Among the above differences, 1, 2 and 5 could be to solve by some tricky way. According to my survey in the code base, the legacy method used in most scenarios can be directly replaced. The following scenarios (just list a part of them) may need to be implemented in other ways:
There are still many other issues caused by differences 3 / 4 / 6. Seems the whatwg-URL is more suitable for standard URL situation. |
@wanglam thanks for a very good deepdive into the issue. I think you have called out the risks accurately here. the whatwg-url does not appear to be ready as a drop in replacement for all our Whatwg-url was introduced to standardize browser url's but has some issues when used in node environments. There are open issues in other prominent repo's that cannot deprecate their uses of |
+1. We should definitely first focus on the obvious/easy low-hanging fruit. If we could remove like 90% of the deprecated usage that would be great. |
@joshuarrrr @ashwin-pc I create a PR(#2910 ) about this issue. Could you help me to review it? |
Thanks @wanglam! We'll schedule it for review. With the holiday week it may realistically be next week that we can pick it up. |
Just a side note:
There is no urgency to getting rid of |
Replace the url.parse/url.format/url.resolve function in the code base with whatwg-url. The main change is to change the url.parse to new URL(), and change url.format to [URL object].toString and change the url.resolve to new URL() toString(). Another major change is to replace the url parts in test config with URL object for transmission. Partially completes #1561 Signed-off-by: Lin Wang <[email protected]> Co-authored-by: Josh Romero <[email protected]>
#2910 fixed much of the low hanging fruit. See #1561 (comment) for remaining tasks. |
…ch-project#2910) Replace the url.parse/url.format/url.resolve function in the code base with whatwg-url. The main change is to change the url.parse to new URL(), and change url.format to [URL object].toString and change the url.resolve to new URL() toString(). Another major change is to replace the url parts in test config with URL object for transmission. Partially completes opensearch-project#1561 Signed-off-by: Lin Wang <[email protected]> Co-authored-by: Josh Romero <[email protected]>
Hello! is it possible to create issues out of remaining tasks, I am not exactly sure what is our remaining? I think we need more clarity for this issue to be closed. As I saw from https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2910/files For example we still have: if (!opensearchUrl && config) { but in: https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2910/files the code was replace with: if (!opensearchUrl && config) { Could you please clarify on this part? Thank you in advance! |
Hi @Aigerim-ai , have you update your forked repository main branch? Seems the merged commit wasn't exists in your branch. I can't find code like I have searched all the The remaining files need to deal with the relative URL. For now, the URL object is hard to process this part. |
…ch-project#2910) Replace the url.parse/url.format/url.resolve function in the code base with whatwg-url. The main change is to change the url.parse to new URL(), and change url.format to [URL object].toString and change the url.resolve to new URL() toString(). Another major change is to replace the url parts in test config with URL object for transmission. Partially completes opensearch-project#1561 Signed-off-by: Lin Wang <[email protected]> Co-authored-by: Josh Romero <[email protected]> Signed-off-by: David Sinclair <[email protected]>
These have been deprecated since node v11.0.0. The recommendation is to "Use the WHATWG URL API" instead.
Parsing can generally be done through the
new URL()
constructor pattern.format()
still exists, although the signature has changed, and it may no longer be needed in many places.(via #1553 (comment))
The text was updated successfully, but these errors were encountered: