Skip to content

Commit

Permalink
fix: sanitize slashes in filepaths
Browse files Browse the repository at this point in the history
  • Loading branch information
Princesseuh committed Apr 29, 2024
1 parent cd01367 commit 5c3a75f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/astro/src/core/build/static-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ import * as vite from 'vite';
import type { RouteData } from '../../@types/astro.js';
import { PROPAGATED_ASSET_FLAG } from '../../content/consts.js';
import { hasAnyContentFlag } from '../../content/utils.js';
import { type BuildInternals, createBuildInternals, getPageDatasWithPublicKey } from '../../core/build/internal.js';
import {
type BuildInternals,
createBuildInternals,
getPageDatasWithPublicKey,
} from '../../core/build/internal.js';
import { emptyDir, removeEmptyDirs } from '../../core/fs/index.js';
import { appendForwardSlash, prependForwardSlash, removeFileExtension } from '../../core/path.js';
import { isModeServerWithNoAdapter } from '../../core/util.js';
Expand Down Expand Up @@ -373,7 +377,11 @@ async function cleanStaticOutput(
const { moduleSpecifier } = pageData;
const pageBundleId = internals.pageToBundleMap.get(moduleSpecifier);
const entryBundleId = internals.entrySpecifierToBundleMap.get(moduleSpecifier);
if (pageData.route.prerender && !pageData.hasSharedModules && allStaticFiles.has(pageBundleId ?? entryBundleId)) {
if (
pageData.route.prerender &&
!pageData.hasSharedModules &&
allStaticFiles.has(pageBundleId ?? entryBundleId)
) {
allStaticFiles.add(pageBundleId ?? entryBundleId);
} else {
// Check if the page pageBundleId or entryBundleId is already in the set, if so, remove it
Expand Down Expand Up @@ -536,6 +544,7 @@ export function makeAstroPageEntryPointFileName(
return `pages${name
.replace(/\/$/, '/index')
.replaceAll(/[[\]]/g, '_')
.replaceAll('/', '-')
.replaceAll('...', '---')}.astro.mjs`;
}

Expand Down

0 comments on commit 5c3a75f

Please sign in to comment.