deepgram-js-sdk
deepgram-js-sdk copied to clipboard
chore: simplify regex
- We already do toLowerCase(), so don't need
iflag. - We're not using the http bit, so no need to capture it.
- If there's an s, append it, if not don't. This is the same as just replacing http with ws:
- [http]:// -> [ws]://
- [http]s:// -> [ws]s://
- [http]x:// -> [ws]x:// -> error. Is ok.
- [http]sx:// -> [ws]sx:// -> error in both. Is ok.
- We don't want to replace protocols that do not start with http, such as git+https, so we can anchor at string start and leave out the
gflag.
Much simpler -:)
Oh it's possible this is different as of #273, I can't remember if I replaced this code or moved it