Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Oct 31, 2024
1 parent b361844 commit cff5807
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/presets/cloudflare/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { join, resolve } from "pathe";
import { isCI } from "std-env";
import {
joinURL,
withBase,
hasProtocol,
withLeadingSlash,
withTrailingSlash,
withoutLeadingSlash,
Expand Down Expand Up @@ -161,9 +161,11 @@ async function writeCFPagesRedirects(nitro: Nitro) {
([_, routeRules]) => routeRules.redirect
)) {
const code = routeRules.redirect!.statusCode;
contents.unshift(
`${withBase(key.replace("/**", "/*"), nitro.options.baseURL)}\t${withBase(routeRules.redirect!.to, nitro.options.baseURL)}\t${code}`
);
const from = joinURL(nitro.options.baseURL, key.replace("/**", "/*"));
const to = hasProtocol(routeRules.redirect!.to, { acceptRelative: true })
? routeRules.redirect!.to
: joinURL(nitro.options.baseURL, routeRules.redirect!.to);
contents.unshift(`${from}\t${to}\t${code}`);
}

if (existsSync(redirectsPath)) {
Expand Down

0 comments on commit cff5807

Please sign in to comment.