Skip to content

Data URLs can't have query params #54944

Description

@avivkeller

Version

main

Platform

N/A

Subsystem

No response

What steps will reproduce the bug?

await import("data:text/javascript,console.log(import.meta.url)?query")

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

Everytime

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

The Data URL should load correctly, printing the import.meta.url with the query

What do you see instead?

SyntaxError: Unexpected end of input

Additional information

I believe this is due to #54748 (CC @KhafraDev)

Activity

  1. added
    confirmed-bugIssues and PRs for confirmed bugs.
    loadersIssues and PRs related to ES module loaders.
    fetchIssues and PRs related to the Fetch API.
    on Sep 14, 2024
  2. KhafraDev commented on Sep 14, 2024

    @KhafraDev
    Member

    The parser is correct here. It doesn't work in Chrome or Firefox nor could I find anywhere in the spec that says to treat query params separately from the body.

    If I'm wrong please correct me.

    Treating query params separately creates a myriad of issues that moving to a dedicated parser aimed to fix; should the question mark in data:text/javascript;console.log('?') be treated as a query param?

  3. avivkeller commented on Sep 14, 2024

    @avivkeller
    MemberAuthor

    Shouldn't that PR become semver-major, as it modifies the existing behavior?

  4. KhafraDev commented on Sep 15, 2024

    @KhafraDev
    Member

    I'd consider it a bug fix so not a semver-major change, we've done this a few times in undici. @nodejs/web-standards

  5. aduh95 commented on Sep 15, 2024

    @aduh95
    Contributor

    Someone reported the old behavior as a bug: #53775

    It's always tricky to decide whether any change qualifies as a bug fix or as a breaking change (cf XKCD 1172). Do you have a use case for having a query parameter?

  6. avivkeller commented on Sep 15, 2024

    @avivkeller
    MemberAuthor

    Do you have a use case for having a query parameter?

    Not really, I just noticed that this behavior was different in the main branch than the latest release when preparing #54933, and I figured it should be a non-patch change when sent to release lines.

  7. aduh95 commented on Sep 15, 2024

    @aduh95
    Contributor

    IMO we should treat it as a bug fix (i.e. semver-patch): if there’s no use case for it, then it’s not going to break anyone — and it’s going to unbreak a few folks

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

    fetchIssues and PRs related to the Fetch API.loadersIssues and PRs related to ES module loaders.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions