[WIP] Hierarchichal overrides using regex #54
Closed
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.
Do not merge!
An alternative to #53
Existing rules as defined in the original requests are working. But now custom regexes can be used as well when required. The way they can be defined is by tuples containing the domain and a regex over the full URL.
For example, consider the following configuration:
All URLs with
product_idargument in the URL will go throughOVERRIDES_2. Other URLs belonging to the subpathen_gbwill go throughOVERRIDES_1.This brings the best of the two words: using simple
domain_or_morerules can still be used, and they will cover most of the cases. If something more powerful is required, then you can use regex. The fact that we are partitioning bydomainmakes also efficient enough this new approach.Note that in case of collusion of both rules (for example for url http://example.com/en_gb/product?product_id=23 in the former example) those defined as regex has priority. And the priority over different regexes is defined by the order in which the regexes are declared.
The priorities over the
domain_or_morerules is defined according to the hierarchy (tld, domain, subdomain, path, etc), so the order in which they are defined is not affected.There is a possibility: enrich a bit more the
domain_or_morerules by allowing globbing. For example, why not allow to declare rules like example.com/product_id=?. Implementation-wise it is not very hard to do. @kmike what do you think?Note that we are here allowing registering default POs by using the empty string. Theoretically, you can also register regex for the empty domain and then they will be applied for any URL. But I don't think this is something we should promote, as it is not a good practice from the point of view of performance.
TODO: