I have the below urls based on environment separated by hyphen.
In one my code snippets i want to dynamically build the above url based on environment by reading from url (either using $location.host() or window.location.hostname)
can anyone suggest a regex or some code to find out if in the Url there is a envirnment variable (dev/qa)
if(contains dev/qa){
//build url
} else {
//build production url
}
Please suggest the best option using regex/code snippet
As per your earlier comment 'rather than passing qa/dev in regex is there any way where i can get value after hyphen' , how about this instead of regex :
if((window.location.hostname).indexOf('-')>=0){
var env= (window.location.hostname).split('-')[1];
// possible output of env : dev.someurl.com,qa.someurl.com
}
else{
//prod
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With