JavaScript Function using Regex to split URL