-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add parse_with_rel()
for when the rel
parameter MUST be present
#11
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Per the crate regex documentation, compiling a regular expression is computationally expensive. Thus, it is advantageous when processing multiple Link: headers to use lazy_static! to compile it only once. Also add some comments to struct Link for better doc rendering. Add test cases to achieve 100% code coverage, per tarpaulin.
Implement a feature named "url" which swaps the http::Uri out for a url::Url -- this allows direct use with other popular crates, such as reqwest. Currently, crate url is used by over 2.5k other crates, whereas crate http is only used by about 1.2k other crates (less than half as many). Since many "Link:" headers come from web servers which are giving a relationship between the current page and other pages, very often the URI is actually a URL, and this is known ahead of time. Generally, features which cause semver breaking changes are frowned upon, but there is really no other way that I can see -- implementing traits like From<&Uri> for Url is forbidden. Without this feature, the only other way is to use the raw_uri with Url::parse(), effectively using String as an intermediate format to translate between the two types. Since URLs can't be relative, support for relative refs is lost when this feature is enabled. Documentation (in-code and README.md) as well as test cases are also updated. Tarpaulin reports 100% coverage.
Add a new helper function to simplify the returned HashMap for those cases where we know that the `rel` parameter will be present in the `Link:` header. Update tests and documentation as needed.
Somwhere in the merge process, test_error_from() was duplicated. It was not flagged as a merge conflict (that I could see), but it needed to be removed, regardless.
Codecov Report
@@ Coverage Diff @@
## master #11 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 1 1
Lines 107 144 +37
=========================================
+ Hits 107 144 +37
|
g1eny0ung
approved these changes
Jan 8, 2022
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.
LGTM. 🍺
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In many situations, it is known beforehand that the
Link:
header will have arel
parameter. In that case, theHashMap
key can be simplified fromOption<Rel>
to simplyRel
.This applies on top of #10 and resolves #7