Skip to content

Expected behavior of stringifyUrl with fragmentIdentifier: '' #380

@sni-J

Description

@sni-J

Expected fragmentIdentifier:'' will remove fragment identifier since its type is string | undefined, but it didn't.

Expected Behavior

Current URL https://foo.bar/#top
Expected https://foo.bar/?referrer=share
Result https://foo.bar/?referrer=share#top
const url = queryString.stringifyUrl({
  url: window.location.toString(),
  query: { referrer: "share" },
  fragmentIdentifier: "",
});

How native URL behaves

const url = new URL("https://foo.bar/#top");
url.hash = "";
url.toString(); // -> https://foo.bar/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions