How do I write a swtich for the following conditional?
If the url contains \"foo\", then settings.base_url is \"bar\".
The following is achi
Another option is to use input field of a regexp match result:
str = 'XYZ test';
switch (str) {
case (str.match(/^xyz/) || {}).input:
console.log("Matched a string that starts with 'xyz'");
break;
case (str.match(/test/) || {}).input:
console.log("Matched the 'test' substring");
break;
default:
console.log("Didn't match");
break;
}