fix: serve static file with parens (#2013)
This commit is contained in:
+2
-15
@@ -266,9 +266,8 @@ export class ServerContext {
|
||||
const { localUrl, path, size, contentType, etag } of this.#extractResult
|
||||
.staticFiles
|
||||
) {
|
||||
const route = sanitizePathToRegex(path);
|
||||
staticRoutes[route] = {
|
||||
baseRoute: toBaseRoute(route),
|
||||
staticRoutes[path] = {
|
||||
baseRoute: toBaseRoute(path),
|
||||
methods: {
|
||||
"HEAD": this.#staticFileHandler(
|
||||
localUrl,
|
||||
@@ -589,18 +588,6 @@ export function normalizeURLPath(path: string): string | null {
|
||||
}
|
||||
}
|
||||
|
||||
function sanitizePathToRegex(path: string): string {
|
||||
return path
|
||||
.replaceAll("\*", "\\*")
|
||||
.replaceAll("\+", "\\+")
|
||||
.replaceAll("\?", "\\?")
|
||||
.replaceAll("\{", "\\{")
|
||||
.replaceAll("\}", "\\}")
|
||||
.replaceAll("\(", "\\(")
|
||||
.replaceAll("\)", "\\)")
|
||||
.replaceAll("\:", "\\:");
|
||||
}
|
||||
|
||||
function serializeCSPDirectives(csp: ContentSecurityPolicyDirectives): string {
|
||||
return Object.entries(csp)
|
||||
.filter(([_key, value]) => value !== undefined)
|
||||
|
||||
Reference in New Issue
Block a user