Skip to content

encodeURIComponent in nodejs 22 cuts $ sign instead of escaping #60608

Description

@rusekr

Version

v22.15.1

Platform

Linux localhost.localdomain 6.17.6-1-default #1 SMP PREEMPT_DYNAMIC Wed Oct 29 17:21:06 UTC 2025 (9e452b6) x86_64 x86_64 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

Just write:

node -e "console.log(encodeURIComponent('price$100'))"

and output will be:

price00

instead of:

price%24100

as it works in browser (any chromeish and code in MDN)

It works strangely when $ sing in encoded string. Sometimes like abowe it cuts aftercharacter with it, sometimes it cuts all string as for example in:

node -e "console.log(encodeURIComponent('$a100'))"

it prints nothing.

encodeURI() function behaves same.

May be here is some nodejs specifics about this function?

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

always

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

'$' sign converts to '%24'

What do you see instead?

nothing (empty string)

Additional information

Wrote in "steps to reproduce section".

Found only #33799 issue where stated that encodeURIComponent in nodejs works as in ecmascript standart.

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