Skip to content

withQuery does not encode "?" #301

@Loskir

Description

@Loskir

Environment

ufo 1.6.1

Reproduction

import { withQuery } from 'ufo'

const actual = withQuery('/', { url: 'https://google.com?query=123' })
const expected = `/?url=${encodeURIComponent('https://google.com?query=123')}`

Describe the bug

The withQuery utility does not encode the "?" character that results in incorrect encoding in some cases. For example

Actual: /?url=https:%2F%2Fgoogle.com?query=123
Expected: /?url=https%3A%2F%2Fgoogle.com%3Fquery%3D123

Additional context

No response

Logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions