[rush] Replace deprecated url.parse() with WHATWG URL API#5657
Open
iclanton wants to merge 1 commit intomicrosoft:mainfrom
Open
[rush] Replace deprecated url.parse() with WHATWG URL API#5657iclanton wants to merge 1 commit intomicrosoft:mainfrom
iclanton wants to merge 1 commit intomicrosoft:mainfrom
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Node.js emits a
[DEP0169] DeprecationWarningduring rush-lib tests becauseGit.normalizeGitUrlForComparison()uses the deprecatedurl.parse()API. This PR replaces it with the WHATWGURLconstructor to eliminate the warning.Details
url.parse()withnew URL()inGit.normalizeGitUrlForComparison(), wrapped in a try/catch to handle non-URL strings (local paths, SCP-like syntax already converted to HTTPS, etc.) that cause theURLconstructor to throw.import * as url from 'node:url'.URLAPI normalizes default ports (e.g. port 80 for HTTP is stripped fromhost), which is actually more correct for URL comparison —http://host.xz:80/pathandhttp://host.xz/pathare equivalent. Updated the test expectation accordingly.normalizeGitUrlForComparison()is an internal API used for comparing Git remote URLs.How it was tested
Ran
rushx testin the rush-lib project — all 583 tests pass with 0 failures, and the[DEP0169] DeprecationWarningno longer appears in test output.