sindresorhus / normalize-url

Normalize a URL
MIT License
837 stars 123 forks source link

Syntax Error #92

Closed shchedrakov closed 5 years ago

shchedrakov commented 5 years ago
options = {
    defaultProtocol: 'http:',
    normalizeProtocol: true,
    forceHttp: false,
    forceHttps: false,
    stripAuthentication: true,
    stripHash: false,
    stripWWW: true,
    removeQueryParameters: [/^utm_\w+/i],
    removeTrailingSlash: true,
    removeDirectoryIndex: false,
    sortQueryParameters: true,
    ...options
};

What is it the string ...options? It is a cause if critical error in Edge browser. Can you remove it from the code?

merijndejonge commented 5 years ago

Check out https://stackoverflow.com/questions/53628191/edge-script1028-expected-identifier-string-or-number. Rather frustrating.

sindresorhus commented 5 years ago

This module mainly targets Node.js, not the browser. It's up to you to transpile it with Babel if you want to use it in the browser. You can find a more detailed explanation here: https://github.com/sindresorhus/ama/issues/446

If you use Webpack, check out babel-engine-plugin, which transpiles only the dependencies that needs to be transpiled.

If you use Create React App, upgrade to Create React App v2. It supports automatic transpilation of dependencies, which will make this package just work.