containerise
containerise copied to clipboard
Rules do not work with URLs containing uppercase characters
Rules do not match URLs containing uppercase characters.
This appears to be because all rules are converted to lowercase, and then are tested in a case-sensitive manner:
// From matchesSavedMap()
new RegExp(regex).test(toMatch);
Unfortunately, users don't have control over the URLs used in links, etc. so if a URL contains uppercase characters where a rule's pattern depends on, the rule will not match it.
Example
- URL:
https://signin.ebay.com/ws/eBayISAPI.dll?SignIn&AppName=ImpactEP-EPN-PRD
- Standard eBay login URL, but with different query string for different properties.
- Rule:
- Original:
@https?:\/{2}signin\.ebay\.com\/.+AppName=ImpactEP-EPN.*
- Converted by Containerise:
@https?:\/{2}signin\.ebay\.com\/.+appname=impactep-epn.*
- Original:
- Result: The rule (after lowercase conversion by Containerise) does not match the URL.
Note: The rule's regex pattern has been confirmed to match when the URL was manually converted to lowercase.
I also experienced this, and as a lazy workaround, I simply replaced the uppercase character with the ascii hex code. So your example regex would become:
https?:\/{2}signin\.ebay\.com\/.+\x41pp\x4eame=\x49mpact\x45\x50-\x45\x50\x4e.*
Far from ideal, though
Thanks for the hack @Sazpaimon.
Also experiencing this bug... :( Looking forward to a resolution (I'm too lazy to use ASCII code ;) )
Here's a python oneliner to convert upper case letters to unicode hex escapes. Thanks @Sazpaimon for https://github.com/kintesh/containerise/issues/120#issuecomment-592029826
URL='https://FooBar.com/pathWithTitleCase'
python -c "print(''.join(fr'\x{i.encode().hex()}' if i.isupper() else i for i in '$URL'))"
# Produces https://\x46oo\x42ar.com/path\x57ith\x54itle\x43ase