Just to remind myself… there is no String.startsWith() in Javascript. This bite me once again… Instead you do a regular expression match from the beginning of the string.
To find out whether your Javascript is being executed on a certain domain you do:
if(window.location.hostname).match("^opensourcehacker.com")) { // yes this is our domain } else { // subdomain (might be www.!) or some else domain }
Yours sincerely, The regex hater
Subscribe to RSS feed Follow me on Twitter Follow me on Facebook Follow me Google+
Here you go https://github.com/edtsech/underscore.string
Thanks for this! Worked great for me but I wanted to comment for others that a “(” is missing in your if statement. 🙂