Skip to content
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

fix(node/url): respect process.noDeprecation in url.parse() #16641

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/js/node/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ function urlParse(
parseQueryString?: boolean,
slashesDenoteHost?: boolean,
) {
if (!urlParseWarned && !lazyUtil().isInsideNodeModules()) {
const noDeprecation = process.noDeprecation;
const showDep = noDeprecation == null ? true : !noDeprecation;
if (!urlParseWarned && showDep && !lazyUtil().isInsideNodeModules()) {
urlParseWarned = true;
process.emitWarning(
"`url.parse()` behavior is not standardized and prone to " +
Expand Down
17 changes: 17 additions & 0 deletions test/js/node/url/url.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { bunRunAsScript, bunRun, tempDirWithFiles } from "harness";
import path from "path";
import { parse } from "url";

describe("Url.prototype.parse", () => {
Expand Down Expand Up @@ -79,3 +81,18 @@ it("URL constructor throws ERR_MISSING_ARGS", () => {
// @ts-expect-error
expect(err?.code).toEqual("ERR_MISSING_ARGS");
});

describe("url.parse()", () => {
it("respects process.noDeprecation", () => {
const dir = tempDirWithFiles("url-parse", {
DonIsaac marked this conversation as resolved.
Show resolved Hide resolved
"index.js": `
process.noDeprecation = true;
const { parse } = require("url");
parse("http://example.com");
`,
});

const { stderr } = bunRun(path.join(dir, "index.js"));
expect(stderr).toBeEmpty();
});
});
Loading