Skip to content

Fix invalid URL errors that prevent loading more than 2 pages#7

Open
KarolS wants to merge 3 commits into
fuzetsu:masterfrom
KarolS:patch-1
Open

Fix invalid URL errors that prevent loading more than 2 pages#7
KarolS wants to merge 3 commits into
fuzetsu:masterfrom
KarolS:patch-1

Conversation

@KarolS
Copy link
Copy Markdown
Contributor

@KarolS KarolS commented Dec 13, 2017

Manga Loader on Mangafox on Firefox failed to load more than 2 pages, since it attempted to load 3.html which is not a valid URL. This commit patches it.

Manga Loader on Mangafox on Firefox failed to load more than 2 pages, since it attempted to load `3.html` which is not a valid URL. This commit patches it.
Comment thread manga-loader.user.js Outdated
return elem.href || elem.getAttribute('href');
var href = elem.href || elem.getAttribute('href');
if (!href.startsWith('//') && !href.startsWith('http') && !href.startsWith('#')) {
return window.location.href + "/../" + href;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be missing something here, but is this code specific to Mangafox? Since this change is in the centrally used extractInfo function couldn't it affect a site that returns relative URLs. My main concern is the /../.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least Firefox and Chrome normalize such sequences in URLs. See also https://tools.ietf.org/html/rfc3986#section-6.2.2.3
But you were right that it's not the best way to fix relative URL's, so I sat down for a while more and improved it.
Bato.to still doesn't work though.

Mangahere loads page 3 without the protocol in the URL
There are the following cases to derelativise:
* //a – just add the protocol to get https://a
* /b – just add the host to get http://a/b
* b – take everything up to the last slash of the path (the root document always has an implicit slash, so it's fine) from the current URL and add the relative URL – so http://a/b/ + c = http://a/b/c but http://a/b + c = http://a/c
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

Successfully merging this pull request may close these issues.

2 participants