Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/utils/src/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ export function getSanitizedUrlString(url: PartialURL): string {
// Always filter out authority
.replace(/^.*@/, '[filtered]:[filtered]@')
// Don't show standard :80 (http) and :443 (https) ports to reduce the noise
.replace(':80', '')
.replace(':443', '')) ||
// TODO: Use new URL global if it exists
.replace(/(:80)$/, '')
.replace(/(:443)$/, '')) ||
'';

return `${protocol ? `${protocol}://` : ''}${filteredHost}${path}`;
Expand Down
4 changes: 4 additions & 0 deletions packages/utils/test/url.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ describe('getSanitizedUrlString', () => {
['same-origin url', '/api/v4/users?id=123', '/api/v4/users'],
['url without a protocol', 'example.com', 'example.com'],
['url without a protocol with a path', 'example.com/sub/path?id=123', 'example.com/sub/path'],
['url with port 8080', 'http://172.31.12.144:8080/test', 'http://172.31.12.144:8080/test'],
['url with port 4433', 'http://172.31.12.144:4433/test', 'http://172.31.12.144:4433/test'],
['url with port 443', 'http://172.31.12.144:443/test', 'http://172.31.12.144/test'],
['url with IP and port 80', 'http://172.31.12.144:80/test', 'http://172.31.12.144/test'],
])('returns a sanitized URL for a %s', (_, rawUrl: string, sanitizedURL: string) => {
const urlObject = parseUrl(rawUrl);
expect(getSanitizedUrlString(urlObject)).toEqual(sanitizedURL);
Expand Down