1

I need to add url patterns for a domain that has multiple subdomains in the Url.

For example:

https://demo.site1.mybrand.company/ Where .company is the top-level domain and mybrand is the domain.

The problem is that the demo subdomain can change based on the environment in the app, so it could be demo, or test, or anything, so I would like to make sure that any subdomain with site1.mybrand.company can access the Dynamic Links API and generate links for that Url.

What I have tried:

Firebase docs cite that these are too permission and I am not sure if Firebase supports multi-tier domains such as this.

  • ^https://.*.company/.*$
  • ^https://.*.mybrand.company/.*$
  • ^https://.*.site1.mybrand.company/.*$

Has anyone experienced this situation before or know if this particular scenario is supported?

References:

WrightsCS
  • 50,551
  • 22
  • 134
  • 186

1 Answers1

3

You might use a bit more specific pattern to match either demo or test using an alternation, and extend that to all the allowed names.

^https://(?:demo|test)\.site1\.mybrand\.company/\S*$

The pattern matches:

  • ^ Start of string
  • https:// Match literally
  • (?:demo|test) Match either demo or test
  • \.site1\.mybrand\.company/ Match .site1.mybrand.company/ (note to escape the dot)
  • \S* Match optional non whitespace chars
  • $ End of string

Regex demo

The fourth bird
  • 154,723
  • 16
  • 55
  • 70
  • What if I need to `(?:demo|test)` to be anything? – WrightsCS Jan 25 '22 at 20:31
  • 1
    @WrightsCS you can specifiy what you would allow. You can match 1 or more word characters using `\w+` like `^https://\w+\.site1\.mybrand\.company/\S*$` or you can use a more broader match for any non whitespace character except for a dot like `^https://[^\s.]+\.site1\.mybrand\.company/\S*$` – The fourth bird Jan 25 '22 at 20:34
  • In regex101 these work great and the Urls are matching, but in firebase allowlist, these Urls still arent working – WrightsCS Jan 25 '22 at 21:21
  • @WrightsCS Did you try double escaping the backslash? `^https:\\/\\/[^\\s.]+\\.site1\\.mybrand\\.company/\\S*$` – The fourth bird Jan 25 '22 at 21:24
  • 1
    no, I might have to try that later – WrightsCS Jan 25 '22 at 21:29