Jeppz
Jeppz

Reputation: 982

AngularJS non-ascii query parameter

I've run into a issue where a redirect to an AngularJS page can contain non-ascii characters as a query parameter.

When the query contains /?id=test%F6test the value instantly turns into /?id=undefined (by Angular I presume).

Is there a nice way around this?

Upvotes: 2

Views: 393

Answers (1)

georgeawg
georgeawg

Reputation: 48968

The Unicode code point needs to encoded into UTF-8.

For code point \u00F6, encode it as %C3%B6

console.log(window.encodeURI("testötest"));
console.log(window.encodeURI('\u00F6'));

%F6 must never appear in a valid UTF-8 sequence.

Upvotes: 1

Related Questions