normalizeURL prepends ws:// when necessary.
This commit is contained in:
parent
12147d4fee
commit
967d7fe63a
1
utils.ts
1
utils.ts
|
@ -4,6 +4,7 @@ export const utf8Decoder = new TextDecoder('utf-8')
|
||||||
export const utf8Encoder = new TextEncoder()
|
export const utf8Encoder = new TextEncoder()
|
||||||
|
|
||||||
export function normalizeURL(url: string): string {
|
export function normalizeURL(url: string): string {
|
||||||
|
if (url.indexOf('://') === -1) url = 'wss://' + url
|
||||||
let p = new URL(url)
|
let p = new URL(url)
|
||||||
p.pathname = p.pathname.replace(/\/+/g, '/')
|
p.pathname = p.pathname.replace(/\/+/g, '/')
|
||||||
if (p.pathname.endsWith('/')) p.pathname = p.pathname.slice(0, -1)
|
if (p.pathname.endsWith('/')) p.pathname = p.pathname.slice(0, -1)
|
||||||
|
|
Loading…
Reference in New Issue