Skip to content

Commit

Permalink
@uppy/utils: do not strip www in getSocketHost (#5621)
Browse files Browse the repository at this point in the history
  • Loading branch information
Murderlon authored Feb 3, 2025
1 parent 3efe61b commit 48d0abc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/@uppy/utils/src/getSocketHost.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ describe('getSocketHost', () => {
'wss://foo.bar/a/b/cd?e=fghi&l=k&m=n',
)

expect(getSocketHost('https://www.foo.bar/a/b/cd?e=fghi&l=k&m=n')).toEqual(
'wss://www.foo.bar/a/b/cd?e=fghi&l=k&m=n',
)

expect(getSocketHost('Https://foo.bar/a/b/cd?e=fghi&l=k&m=n')).toEqual(
'wss://foo.bar/a/b/cd?e=fghi&l=k&m=n',
)
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/utils/src/getSocketHost.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default function getSocketHost(url: string): string {
// get the host domain
const regex = /^(?:https?:\/\/|\/\/)?(?:[^@\n]+@)?(?:www\.)?([^\n]+)/i
const regex = /^(?:https?:\/\/|\/\/)?(?:[^@\n]+@)?([^\n]+)/i
const host = regex.exec(url)?.[1]
const socketProtocol = /^http:\/\//i.test(url) ? 'ws' : 'wss'

Expand Down

0 comments on commit 48d0abc

Please sign in to comment.