Skip to content

Commit

Permalink
feat: add url utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
Hebilicious committed Jul 6, 2023
1 parent 324f3f7 commit ae267f6
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/utils/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,20 @@ export function getRequestURL(
const path = getRequestPath(event);
return new URL(path, `${protocol}://${host}`);
}

export function setOriginalUrlPath(event: H3Event, url: string) {
// eslint-disable-next-line @typescript-eslint/no-extra-semi
(event.node.req as any).originalUrlPath = url;
}

export function getOriginalUrlPath(event: H3Event) {
return (event.node.req as any).originalUrlPath as string;
}

export function setUrlPath(event: H3Event, url: string) {
event.node.req.url = url;
}

export function getUrlPath(event: H3Event) {
return event.node.req.url || "/";
}

0 comments on commit ae267f6

Please sign in to comment.