Skip to content
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

url-polyfill is loaded in Safari when not required #14

Closed
nekodex opened this issue Jan 18, 2018 · 6 comments
Closed

url-polyfill is loaded in Safari when not required #14

nekodex opened this issue Jan 18, 2018 · 6 comments

Comments

@nekodex
Copy link

nekodex commented Jan 18, 2018

Seems to be because Safari escapes the pathname set by url-polyfill.js#L173, causing the comparison (u.href === 'http://a/c%20d') to return false:

@supperchong
Copy link

I find the same problem.When I use url-polyfill and pdfjs-dist in my web,the url-polyfill will lose efficacy. Because pdf-dist use this code to check if URL is valid.
if (typeof URL === 'function' && _typeof(URL.prototype) === 'object' && 'origin' in URL.prototype) { var u = new URL('b', 'http://a'); u.pathname = 'c%20d'; hasWorkingUrl = u.href === 'http://a/c%20d'; }
But in safari,
u.href==='http://a/c%2520d'
And then the pdfjs-dist will rewrite URL.But the module doesn't achieve the searchParams method.fortunately the pdfjs-dist have Stop exposing the URL polyfill in the global scope.

More over ,If this is a bug ? url-polyfill use this code to check URL is supported.But after execute the module .The check is false also in safari.
var checkIfURLIsSupported = function() { try { var u = new URL('b', 'http://a'); u.pathname = 'c%20d'; return (u.href === 'http://a/c%20d') && u.searchParams; } catch(e) { return false; } };

@lifaon74
Copy link
Owner

lifaon74 commented Sep 3, 2018

I don't have Safari on the hand. Could you fix it on your side, run the tests and create a pull request please ?

@moshest
Copy link
Contributor

moshest commented Jul 14, 2019

Currently looks like everything works fine (Safari 12.1.1):

Screen Shot 2019-07-14 at 19 10 51

@janicklas-ralph
Copy link
Contributor

This is still an issue in Safari 10. Any idea what should be the fix?

@lifaon74
Copy link
Owner

@janicklas-ralph I dont have any Safari on the hand, could you please fork the project, fix the bug, and then do a pull request ?

lifaon74 added a commit that referenced this issue Jan 29, 2020
@lifaon74
Copy link
Owner

Ok, version 1.1.8 released. Tell if everything is OK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants