Never parse stuff yourself, always use a library.
Core JS library:
8 comments
@nikitonsky either way you’re handing the special case of default port numbers in your code. Feels like a separate normalisation/presentation step would be preferable. @nikitonsky Firefox, but it is the same in all browsers. If a protocol part matches default port (http/80, https/443, ftp/21) then it returns an empty string |
@nikitonsky I've never tried to parse myself. I'm afraid of what I might find if I tried :)