You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 10, 2022. It is now read-only.
Sorry guys,
but if the purpose of this library is to help converting relative links to absolute links I have to say that it doesn't respect any of the specs in the RFC 1808 (https://www.rfc-editor.org/info/rfc1808).
Following your example:
CASE 1:
var converted = converter.convert('<img src="foo.png">', 'http://mysite.com');
result is: <img src="http://mysite.com/foo.png"> which is CORRECT
This is a very simple case but in internet you'll encounter hundreds of different cases.
CASE 2:
var converted = converter.convert('<img src="/images/foo.png">', 'http://mysite.com/context');
result is: <img src="http://mysite.com/context/images/foo.png"> which is WRONG
The RIGHT link is: <img src="http://mysite.com/images/foo.png">. The link starts with a "/" which means that you have to attach it to the domain root.
CASE 3:
var converted = converter.convert('<img src="../foo.png">', 'http://mysite.com/context');
result is: <img src="http://mysite.com/context/../foo.png"> which is WRONG
The RIGHT link is: <img src="http://mysite.com/foo.png">. The link start with "../" which means, like in the file systems, that you have to go up one level.
It's not said the the base url is the domain only, more over this class seems to just concatenate the base_url with current_url without any logic. There other hundreds of cases not covered by this library.
I find strange that no one complained about this until now.
Regards, MadGhigno
The text was updated successfully, but these errors were encountered:
Sorry guys,
but if the purpose of this library is to help converting relative links to absolute links I have to say that it doesn't respect any of the specs in the RFC 1808 (https://www.rfc-editor.org/info/rfc1808).
Following your example:
CASE 1:
var converted = converter.convert('<img src="foo.png">', 'http://mysite.com');
result is:
<img src="http://mysite.com/foo.png">
which is CORRECTThis is a very simple case but in internet you'll encounter hundreds of different cases.
CASE 2:
var converted = converter.convert('<img src="/images/foo.png">', 'http://mysite.com/context');
result is:
<img src="http://mysite.com/context/images/foo.png">
which is WRONGThe RIGHT link is:
<img src="http://mysite.com/images/foo.png">
. The link starts with a "/" which means that you have to attach it to the domain root.CASE 3:
var converted = converter.convert('<img src="../foo.png">', 'http://mysite.com/context');
result is:
<img src="http://mysite.com/context/../foo.png">
which is WRONGThe RIGHT link is:
<img src="http://mysite.com/foo.png">
. The link start with "../" which means, like in the file systems, that you have to go up one level.It's not said the the base url is the domain only, more over this class seems to just concatenate the base_url with current_url without any logic. There other hundreds of cases not covered by this library.
I find strange that no one complained about this until now.
Regards,
MadGhigno
The text was updated successfully, but these errors were encountered: