Problem/Motivation
Currently it's not possible to include include path in environment hostnames.
Use case could be:
I have local development environment at "local.example.com", and I can create environment with that hostname.
I have production environment at "example.com", and I can create environment with that hostname.
I have staging environment at "example.com/staging", but it's not possible add "/staging" in the hostname, because it will cause warning when validating regular expression with forward slashes (/) as pattern delimiters:
Warning: preg_match() [function.preg-match]: Unknown modifier '/' in environment_indicator_ui_validate() (line 236 of /private/var/www/vanilla/sites/all/modules/environment_indicator/environment_indicator.module).
and gives form error for invalid regular expression:
"Hostname must be a valid regular expression."
Proposed resolution
Replace forward slashes (/) with at-signs (@) in regular expression patterns. This way it would be possible to include paths in environment hostnames.
Comment | File | Size | Author |
---|---|---|---|
#5 | environment_indicator-path-in-environment-hostnames-2381171-5.patch | 1.28 KB | ilkkave |
#2 | environment_indicator-path-in-environment-hostnames-2381171-2.patch | 975 bytes | ilkkave |
Comments
Comment #1
ilkkave CreditAttribution: ilkkave commentedComment #2
ilkkave CreditAttribution: ilkkave commentedHere's a patch to change forward slashes (/) to at-signs (@) in regular expression patterns where needed, to allow path to be included in environment hostnames.
Comment #3
ilkkave CreditAttribution: ilkkave commentedComment #4
e0ipsoInstead of changing the delimiter we should probably fix the underlying bug and use preg_quote. Something like:
Comment #5
ilkkave CreditAttribution: ilkkave commentedThanks for the tip. preg_quote can be used when validating the hostname, but not when checking the environment hostname against hostname from the server, because eg. default environment wouldn't be matched in that case.
So here's a refined patch. I also added base path when checking environment hostname against current hostname, as it's needed to match path in the hostname.
Comment #7
e0ipsoMerged. Thanks!