Skip to content

Commit a340aff

Browse files
Copilothuntie
andcommitted
refactor: use ordinary import for strict-url-sanitise
Co-authored-by: huntie <2547783+huntie@users.noreply.github.com>
1 parent 08bba3f commit a340aff

1 file changed

Lines changed: 1 addition & 12 deletions

File tree

packages/cli-server-api/src/openURLMiddleware.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,7 @@ import type {IncomingMessage, ServerResponse} from 'http';
1010
import {json} from 'body-parser';
1111
import connect from 'connect';
1212
import open from 'open';
13-
14-
// Cache the imported sanitizeUrl function to avoid repeated dynamic imports
15-
let sanitizeUrlFn: ((url: string) => string) | null = null;
16-
17-
async function getSanitizeUrl(): Promise<(url: string) => string> {
18-
if (sanitizeUrlFn === null) {
19-
const module = await import('strict-url-sanitise');
20-
sanitizeUrlFn = module.sanitizeUrl;
21-
}
22-
return sanitizeUrlFn;
23-
}
13+
import {sanitizeUrl} from 'strict-url-sanitise';
2414

2515
/**
2616
* Open a URL in the system browser.
@@ -50,7 +40,6 @@ export async function openURLMiddleware(
5040

5141
let sanitizedUrl: string;
5242
try {
53-
const sanitizeUrl = await getSanitizeUrl();
5443
sanitizedUrl = sanitizeUrl(url);
5544
} catch {
5645
res.writeHead(400);

0 commit comments

Comments
 (0)