-
Notifications
You must be signed in to change notification settings - Fork 3
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
[#270] Handle relative redirects #271
Conversation
src/Xrefcheck/Verify.hs
Outdated
Just nextLink -> do | ||
nextUri <- ExternalResourceUriParseError `withExceptT` parseUri True nextLink | ||
nextLinkAbsolute <- case relativeTo nextUri uri of | ||
Nothing -> error "Not absolute URL exception" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not happen because uri has been parsed with parseUri False
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would put this explanation as code comment, it seems worthy.
Nothing -> throwError $ RedirectMissingLocation $ followed `pushRequest` RedirectChainLink link | ||
Just nextLink -> do | ||
nextUri <- ExternalResourceUriParseError `withExceptT` parseUri True nextLink | ||
nextLinkAbsolute <- case relativeTo nextUri uri of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mainly used the relativeTo
function from the modern-uri
package for this task. This is how we obtain the absolute target link from the (absolute) source + the (absolute or relative) target.
-- configurations of this type is 'strictURIParserOptions', which follows | ||
-- RFC 3986, and the other -- 'laxURIParseOptions' -- allows brackets | ||
-- in the queries, which draws us closer to the WHATWG URL standard. | ||
uri <- case URIBS.parseURI URIBS.laxURIParserOptions (encodeUtf8 link) of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The modern-uri
package can parse an URI deciding if it is absolute or relative depending on the success or failure of the scheme parsing. In uri-bytestring
, it has to be decided beforehand, resulting in different URI types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks for implementing it this soon.
d2c778b
to
ac02933
Compare
Problem: Currently, Xrefcheck can follow redirects with an absolute location link, but it cannot handle relative ones. Solution: After parsing the location link, obtain the corresponding absolute link by using the original request one.
ac02933
to
9c2ac77
Compare
Description
Problem: Currently, Xrefcheck can follow redirects with an absolute location link, but it cannot handle relative ones.
Solution: After parsing the location link, obtain the corresponding absolute link by using the original request one.
Related issue(s)
Fixes #270
Related changes (conditional)
Tests
silently reappearing again.
Documentation
Public contracts
of Public Contracts policy.
and
Stylistic guide (mandatory)