Skip to content

Comments

[rush] Replace deprecated url.parse() with WHATWG URL API#5657

Open
iclanton wants to merge 1 commit intomicrosoft:mainfrom
iclanton:fix-url-deprecation-warning
Open

[rush] Replace deprecated url.parse() with WHATWG URL API#5657
iclanton wants to merge 1 commit intomicrosoft:mainfrom
iclanton:fix-url-deprecation-warning

Conversation

@iclanton
Copy link
Member

Summary

Node.js emits a [DEP0169] DeprecationWarning during rush-lib tests because Git.normalizeGitUrlForComparison() uses the deprecated url.parse() API. This PR replaces it with the WHATWG URL constructor to eliminate the warning.

Details

  • Replaced url.parse() with new URL() in Git.normalizeGitUrlForComparison(), wrapped in a try/catch to handle non-URL strings (local paths, SCP-like syntax already converted to HTTPS, etc.) that cause the URL constructor to throw.
  • Removed the now-unused import * as url from 'node:url'.
  • The WHATWG URL API normalizes default ports (e.g. port 80 for HTTP is stripped from host), which is actually more correct for URL comparison — http://host.xz:80/path and http://host.xz/path are equivalent. Updated the test expectation accordingly.
  • No backwards compatibility concerns; normalizeGitUrlForComparison() is an internal API used for comparing Git remote URLs.

How it was tested

Ran rushx test in the rush-lib project — all 583 tests pass with 0 failures, and the [DEP0169] DeprecationWarning no longer appears in test output.

…Git.normalizeGitUrlForComparison

Replace the deprecated Node.js url.parse() call with the WHATWG URL
constructor in Git.normalizeGitUrlForComparison(). The URL constructor
is wrapped in a try/catch to gracefully handle non-URL strings (local
paths, etc.) that would throw.

The WHATWG URL API correctly strips default ports (e.g. port 80 for
HTTP), which is more correct for URL comparison purposes. Updated the
corresponding test expectation accordingly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs triage

Development

Successfully merging this pull request may close these issues.

1 participant