Skip to content

Remove Deprecated use of url.parse - #389

Open
rajmishra1997 wants to merge 8 commits into
masterfrom
users/rajmishra/RemoveURL
Open

Remove Deprecated use of url.parse #389
rajmishra1997 wants to merge 8 commits into
masterfrom
users/rajmishra/RemoveURL

Conversation

@rajmishra1997

@rajmishra1997 rajmishra1997 commented Dec 24, 2025

Copy link
Copy Markdown
Contributor

Deprecation in Node 24: https://nodejs.org/api/deprecations.html#DEP0169

This PR updates use of url.parse to Safer New URL()
Impacts how request object is formed by rest-client

@rajmishra1997
rajmishra1997 requested review from a team as code owners December 24, 2025 15:16
Comment thread lib/HttpClient.ts
@rajmishra1997 rajmishra1997 changed the title Remove Deprecated use of url.parse [Draft]Remove Deprecated use of url.parse Dec 29, 2025

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates from the deprecated Node.js url.parse() API (deprecated in Node 24 as DEP0169) to the WHATWG URL() constructor. The changes update URL parsing logic across the HTTP client library to use the modern URL API while attempting to preserve existing behavior.

Changes:

  • Replaced url.parse() with new URL() constructor throughout the codebase
  • Updated type signatures from url.Url to URL in interfaces and method signatures
  • Refactored URL merging logic in Util.getUrl() to handle relative and absolute URLs with the new API
  • Added error handling for invalid URLs during parsing

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
lib/Util.ts Refactored getUrl() function to use URL constructor, with logic to detect and handle relative vs absolute resource URLs, manual URL construction for path merging
lib/Interfaces.ts Updated IRequestInfo interface to use URL type instead of url.Url
lib/HttpClient.ts Updated all url.parse() calls to new URL(), changed type signatures, replaced url.format() with .href property
test/units/utiltests.ts Updated test cases to use new URL() instead of url.parse()

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/Util.ts Outdated
Comment thread lib/Util.ts Outdated
Comment thread lib/HttpClient.ts Outdated
@rajmishra1997 rajmishra1997 changed the title [Draft]Remove Deprecated use of url.parse Remove Deprecated use of url.parse Mar 22, 2026
@rajmishra1997
rajmishra1997 requested a review from Copilot March 22, 2026 14:33
@rajmishra1997

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/Util.ts Outdated
Comment thread lib/Interfaces.ts
Comment thread lib/HttpClient.ts Outdated
Comment thread lib/HttpClient.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 8 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/HttpClient.ts
Comment thread test/units/utiltests.ts
Comment thread lib/Util.ts
Comment thread lib/Util.ts
Comment thread lib/Util.ts
Comment thread lib/HttpClient.ts
Comment thread lib/HttpClient.ts
Comment thread lib/Interfaces.ts
@rajmishra1997

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@rajmishra1997

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

Comment thread lib/Util.ts
} else {
// Resource is a relative path - merge with base using path.resolve
const protocol = base.protocol;
const encodedUsername = base.username ? encodeURIComponent(base.username) : '';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

username and password here can contain special characters?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, urlstores username/password in decoded form (e.g., %40 becomes @). When we reconstruct the URL string manually, we must use
encodeURIComponent() to re-encode special character

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

1 similar comment
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

rajmishra1997 and others added 2 commits May 18, 2026 14:53
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
rajmishra1997 and others added 4 commits May 18, 2026 14:53
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@rajmishra1997
rajmishra1997 force-pushed the users/rajmishra/RemoveURL branch from dc853e3 to 8d411cc Compare May 18, 2026 09:25
@rajmishra1997

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

Comment thread lib/HttpClient.ts
}

private _isMatchInBypassProxyList(parsedUrl: url.Url): Boolean {
private _isMatchInBypassProxyList(parsedUrl: URL): Boolean {

@raujaiswal raujaiswal May 18, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we please check if we can use boolean here that is primitive type instead of object Type Boolean?

Comment thread lib/HttpClient.ts
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

import url = require("url");

@raujaiswal raujaiswal May 18, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we please check if we need this url import in this file and other file since we removed url.parse?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants