stoically / temporary-containers

Firefox Add-on that lets you open automatically managed disposable containers
https://addons.mozilla.org/firefox/addon/temporary-containers/
MIT License
846 stars 57 forks source link

Per domain isolation pattern effeciency #610

Open Gitoffthelawn opened 1 year ago

Gitoffthelawn commented 1 year ago

When specifying domain patterns for per domain isolation, one can specify patterns as literals, wildcards, or regexes. See https://github.com/stoically/temporary-containers/wiki/Per-Domain-Isolation

To prevent leakage, I find it best to isolate domains whether or not a host is specified. Thus, there are 2 choices:

  1. Specifying 2 domain patterns (1 literal and 1 wildcard): example.com and *.example.com
  2. Specifying a single regex pattern: /^https?://(?:[^.]+\.|)example\.com/

Both options should match the same URLs. Based on how TC processes per-domain isolation patterns, which will be more efficient, the 1st or the 2nd?

Gitoffthelawn commented 1 year ago

Looking closely at the code, I'm thinking the second option may be more efficient, because it looks like all globs/wildcards are converted to regex and then reprocessed: https://github.com/stoically/temporary-containers/blob/d66d9b601d44c36a57b7a91e7cc6db67f6c047f8/src/background/utils.ts#L40

Is that correct?