[ci] format

This commit is contained in:
matthewp 2022-04-21 18:03:47 +00:00 committed by github-actions[bot]
parent 637919c8b6
commit c4203ce0fc
4 changed files with 12 additions and 10 deletions

View file

@ -178,9 +178,10 @@ async function generatePath(
// If a base path was provided, append it to the site URL. This ensures that // If a base path was provided, append it to the site URL. This ensures that
// all injected scripts and links are referenced relative to the site and subpath. // all injected scripts and links are referenced relative to the site and subpath.
const site = astroConfig.base && astroConfig.base !== './' const site =
? joinPaths(astroConfig.site?.toString() || 'http://localhost/', astroConfig.base) astroConfig.base && astroConfig.base !== './'
: astroConfig.site; ? joinPaths(astroConfig.site?.toString() || 'http://localhost/', astroConfig.base)
: astroConfig.site;
const links = createLinkStylesheetElementSet(linkIds.reverse(), site); const links = createLinkStylesheetElementSet(linkIds.reverse(), site);
const scripts = createModuleScriptElementWithSrcSet(hoistedId ? [hoistedId] : [], site); const scripts = createModuleScriptElementWithSrcSet(hoistedId ? [hoistedId] : [], site);

View file

@ -45,4 +45,4 @@ function isString(path: unknown): path is string {
export function joinPaths(...paths: (string | undefined)[]) { export function joinPaths(...paths: (string | undefined)[]) {
return paths.filter(isString).map(trimSlashes).join('/'); return paths.filter(isString).map(trimSlashes).join('/');
} }

View file

@ -112,11 +112,12 @@ async function handle404Response(
html = subpathNotUsedTemplate(devRoot, pathname); html = subpathNotUsedTemplate(devRoot, pathname);
} else { } else {
// HACK: redirect without the base path for assets in publicDir // HACK: redirect without the base path for assets in publicDir
const redirectTo = const redirectTo =
req.method === 'GET' req.method === 'GET' &&
&& config.base && config.base !== './' config.base &&
&& pathname.startsWith(config.base) config.base !== './' &&
&& pathname.replace(config.base, '/'); pathname.startsWith(config.base) &&
pathname.replace(config.base, '/');
if (redirectTo && redirectTo !== '/') { if (redirectTo && redirectTo !== '/') {
const response = new Response(null, { const response = new Response(null, {

View file

@ -8,7 +8,7 @@ function addLeadingSlash(path) {
function removeBasePath(path) { function removeBasePath(path) {
// `/subpath` is defined in the test fixture's Astro config // `/subpath` is defined in the test fixture's Astro config
return path.replace('/subpath', '') return path.replace('/subpath', '');
} }
/** /**