Stop treating those href and src values as if they were just strings. Think about them as Objects with properties and methods.
Forget wasting time with the String methods for splitting and parsing the values from the href and src values. Use a SearchParams Object.

#html5

HTML5 URL and SearchParams Objects
1.25 GEEK