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
Protocol-relative URLs aren't handled correctly. They are currently processed as relative when they are designed to be used for external resources. This has a knock on effect where these types of links are returned by Document#internal_links instead of external_links.
url=Wgit::Url.new'//fonts.google.com'url.relative?# true - which isn't right, it should be false.
Expected Behavior
Url#relative? should return false for a protocol relative URL.
Document#external_links should return any protocol relative URLs, not internal_links. The returned URLs should have the correct @url.scheme prefixed so they are valid?.
Possible Solutions
Point 1 above can be achieved by adding the following line (not tested):
# Add this to Wgit::Url#relative? on line 164returnfalseifstarts_with?('//)
Point 2 above can be achieved with something like (not tested):
# Replace this method in the Wgit::Document classdefexternal_linksreturn[]if@links.empty?links=@links.mapdo |link|
link=Wgit::Url.new("#{@url.scheme}:#{link}")iflink.start_with?('//')link.omit_trailing_slashend.reject{ |link| link.relative?(host: @url.to_origin)}Wgit::Utils.sanitize(links)end
Tests
What tests would prove this bug is fixed?
See the expected behavior and write tests to assert it.
The text was updated successfully, but these errors were encountered:
Description
Protocol-relative URLs aren't handled correctly. They are currently processed as relative when they are designed to be used for external resources. This has a knock on effect where these types of links are returned by
Document#internal_links
instead ofexternal_links
.Additional reading: https://www.paulirish.com/2010/the-protocol-relative-url/
Reproduce
Steps to reproduce the behavior:
Expected Behavior
Url#relative?
should return false for a protocol relative URL.Document#external_links
should return any protocol relative URLs, notinternal_links
. The returned URLs should have the correct@url.scheme
prefixed so they arevalid?
.Possible Solutions
Point 1 above can be achieved by adding the following line (not tested):
Point 2 above can be achieved with something like (not tested):
Tests
What tests would prove this bug is fixed?
The text was updated successfully, but these errors were encountered: