mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
feat: new helper functions to replace regexes #807
Implemented new StringUtil helper functions: splitCommaSeparated, sanitizeUrlPart, isValidFileName. Added helper functions to HeaderUtil: matchesAuthorizationScheme, hasScheme. Added unit tests for the new helper functions. Refactored codebase to use helper functions instead of regexes if applicable.
This commit is contained in:
committed by
Joachim Van Herwegen
parent
1b7cc1ea3a
commit
283c301f08
@@ -1,4 +1,4 @@
|
||||
import { addHeader } from '../../util/HeaderUtil';
|
||||
import { addHeader, hasScheme } from '../../util/HeaderUtil';
|
||||
import { HttpHandler } from '../HttpHandler';
|
||||
import type { HttpResponse } from '../HttpResponse';
|
||||
|
||||
@@ -11,7 +11,7 @@ export class WebSocketAdvertiser extends HttpHandler {
|
||||
public constructor(baseUrl: string) {
|
||||
super();
|
||||
const socketUrl = new URL(baseUrl);
|
||||
socketUrl.protocol = /^(?:http|ws):/u.test(baseUrl) ? 'ws:' : 'wss:';
|
||||
socketUrl.protocol = hasScheme(baseUrl, 'http', 'ws') ? 'ws:' : 'wss:';
|
||||
this.socketUrl = socketUrl.href;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user