livecheck: move #preprocess_url
into strategies
#18455
Merged
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.
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?Livecheck#preprocess_url
only contains logic for rewriting Git URLs, so it makes more sense for this code to be part of theGit
strategy instead. Outside of better code organization, this saves us from having to maintain the list of strategies to skip processing (which is sometimes forgotten when a new strategy is added) and makes it easier to do something similar in other strategies as needed.One thing to note is that
Livecheck#preprocess_url
was previously called on the URL before each strategy's#match?
method was called. To maintain the existing behavior, this callsGit#preprocess_url
inGit#match?
. However, we need the processed URL when we use theGit
strategy, so we have to callGit#preprocess_url
again. To avoid duplicating effort, I've added a@processed_urls
hash to theGit
strategy and have set upGit#preprocess_url
to cache processed URLs, so we only do the work once. There may be a better way of handling it but this seems to work as expected.