-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
URIError: Malformed encodeURI input #41
Comments
@bradzickafoose would you check and see if your toolchain is preserving the 'u' in the '/gu' part of the regular expression? this runs for me ['😎', '😅', '😍', '👀'].map(value => String(value)
.replace(/[^ !'()~*]/gu, encodeURIComponent)
.replace(/ /g, '+')
.replace(/[!'()~*]/g, ch =>
`%${ch.charCodeAt().toString(16).slice(-2).toUpperCase()}`)) |
@bradzickafoose if you are using babel, and if babel is removing the unicode 'u' from the regular expression, you might try using this plugin https://babeljs.io/docs/en/babel-plugin-proposal-unicode-property-regex |
I'm closing this because I can't reproduce it and there is no reply here. Feel free to re-open or send a message if you feel there is an issue. |
Thank you for your help. The only way I could get it to not throw a URIError was to replace the I tried the solution you suggested but that didn't work, in this case. |
@bradzickafoose I'm interested to update this package if there is an issue with iOS and Android environments. Would you try this 'encode' variant which does not use the unicode regex flag? do react native generated sources using this regexp run correctly in iOS and Android? var encode = function encode(value) {
return String(value).replace(/(?:[\0-\x1F"-&\+-\}\x7F-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/g, encodeURIComponent).replace(/ /g, '+').replace(/[!'()~*]/g, function (ch) {
return "%".concat(ch.charCodeAt().toString(16).slice(-2).toUpperCase());
});
}; |
perhaps this issue is related facebook/react-native#29807 |
I'm seeing a "URIError: Malformed encodeURI input" error at
encodeURIComponent
when emoji are passed in as thevalue
toencode(value)
.It looks like the error is coming from line 7,
.replace(/[^ !'()~*]/gu, encodeURIComponent)
, whenencode(value)
is called withinnest
on line 34,f = encode(name) + '=' + encode(value);
.The error doesn't occur on all emoji.
Here are a few emoji that have triggered the error in React Native on iOS and Android: 😎, 😅, 😍, 👀
The text was updated successfully, but these errors were encountered: