deepgram-js-sdk icon indicating copy to clipboard operation
deepgram-js-sdk copied to clipboard

chore: simplify regex

Open msopacua opened this issue 1 year ago • 1 comments

  • We already do toLowerCase(), so don't need i flag.
  • 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 g flag.

Much simpler -:)

msopacua avatar May 02 '24 09:05 msopacua

Oh it's possible this is different as of #273, I can't remember if I replaced this code or moved it

lukeocodes avatar May 02 '24 14:05 lukeocodes