镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

URL.href adds a trailing slash at end, but browsers don't #45216

Description

@markcellus

Version

v16.15.1

Platform

Linux [redacted] 5.15.0-52-generic #58-Ubuntu SMP Thu Oct 13 08:03:55 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

In node do the following

new URL(`https://abc.xyz`).href

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

N/A

What is the expected behavior?

'https://abc.com'

What do you see instead?

'https://abc.com/'

Additional information

I'm assuming the the URL module in Node is meant to be interoperable with the DOM W3C URL specification. Since doing this command in a browser doesn't produce a trailing slash, it appears to be a bug for Node to add one.

Activity

  1. markcellus commented on Oct 27, 2022

    @markcellus
    Author

    Hmm it appears that the Location.href in the browser returns it without the trailing slash. So I was mistaken thinking Location is synonymous with URL. Closing.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions