Skip to content

Commit

Permalink
feat(server): support resolvePath
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Mar 7, 2023
1 parent fd57eed commit 4717851
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const MethodToTypeMap = {

export interface StorageServerOptions {
authorize?: (request: StorageServerRequest) => void | Promise<void>;
resolvePath?: (event: H3Event) => string;
}

export function createH3StorageHandler(
Expand All @@ -41,10 +42,9 @@ export function createH3StorageHandler(
): EventHandler {
return eventHandler(async (event) => {
const method = getMethod(event);
const isBaseKey = event.path.endsWith(":") || event.path.endsWith("/");
const key = isBaseKey
? normalizeBaseKey(event.path)
: normalizeKey(event.path);
const _path = opts.resolvePath?.(event) ?? event.path;
const isBaseKey = _path.endsWith(":") || _path.endsWith("/");
const key = isBaseKey ? normalizeBaseKey(_path) : normalizeKey(_path);

// Authorize Request
try {
Expand Down

0 comments on commit 4717851

Please sign in to comment.