Skip to content

URL.parse fails on URLs with comma separated hosts #48850

@evansnicholas

Description

@evansnicholas

Version

v18.17.0

Platform

Linux XXXXX 5.4.0-137-generic #154-Ubuntu SMP Thu Jan 5 17:03:22 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

Parsing URL's with comma separated hosts throws a TypeError [ERR_INVALID_URL]: Invalid URL error. This URL parsed correctly in in node v18.16.1.

const URL = require('url');
URL.parse("mongodb://127.0.0.1,127.0.0.2:27017")

How often does it reproduce? Is there a required condition?

Always.

What is the expected behavior? Why is that the expected behavior?

URL parsed rather than exception thrown.

What do you see instead?

An exception is thrown.

Additional information

This is a serious problem because such URL's are used reguarly when configuring eg DB connections which now fail. This is the case with the MongoDB driver for instance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    urlIssues and PRs related to the legacy built-in url module.v18.xIssues that can be reproduced on v18.x or PRs targeting the v18.x-staging branch.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions