Skip to content

Commit

Permalink
Stronger path creator
Browse files Browse the repository at this point in the history
  • Loading branch information
victrme committed Jan 24, 2025
1 parent 5366edb commit c79824d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions package/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ export function fullpath(url: string, query: string): string {
return ""
}

const { pathname, hostname, protocol } = new URL(query)
const { protocol, origin } = new URL(query)
let { pathname } = new URL(query)

if (url.startsWith("http")) {
return url
Expand All @@ -50,10 +51,14 @@ export function fullpath(url: string, query: string): string {
return `${protocol}${url}`
}

if (pathname === "/") {
pathname = ""
}

if (url.startsWith("/")) {
return `${protocol}//${hostname}${pathname}${url}`
return `${origin}${url}`
} else {
return `${protocol}//${hostname}/${url}`
return `${origin}${pathname}${url}`
}
}

Expand Down
2 changes: 1 addition & 1 deletion package/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export async function faviconAsFetch(request: Request): Promise<Response> {
async function main(query: string, fast: boolean, as: "blob"): Promise<Blob>
async function main(query: string, fast: boolean, as: "text"): Promise<string>
async function main(query: string, fast: boolean, as: "blob" | "text") {
// log.init("PATHS")
log.init("PATHS")

const found = await createFaviconList(query)
const hasOneIcon = found.length === 1
Expand Down

0 comments on commit c79824d

Please sign in to comment.