SyntaxError: "missing ( before catch"
Kolobok12309 opened this issue · 2 comments
Environment
chrome 75.0.3770
and firefox 67
and other
Reproduction
Run ufo
code from browser like chrome 75.0.3770
Describe the bug
SyntaxError: "missing ( before catch"
Error from this fragment
Lines 117 to 123 in ab3d4eb
Additional context
Simple replace catch {
-> catch (err) {
fix it
Logs
No response
Optional catch binding seems to have been supported since Chrome 66 and Firefox 58 (link).
Actually it is working as far as I tested in the following way.
-
Create
web
directory in the root of this repository -
Create
index.html
in the directory with the content below:<!DOCTYPE html> <html lang="en"> <head> <title>Reproduction</title> </head> <body> <script type="module"> import * as ufo from './index.js' console.log(ufo.decode('%3F')) console.log(ufo.decode('%malformed')) </script> </body> </html>
-
Build
ufo
package (i.e.pnpm run build
) and copydist/index.mjs
toweb/index.mjs
-
Run
npx serve ./web
and access tolocalhost:3000
-
See the console
-
'%3F'
is successfully decoded to'?'
-
'%malformed'
throws an error internally (i.e.decodeURIComponent('%malformed')
) and fell back to'%malformed'
We could investigate this issue in more depth with a reproduction. 🙌
@nozomuikuta In modern browsers it works as expected yes, my fail, need update babel for catching "optional catch"