}
function sanitizeAssetPath(assetPath: string) {
- const matches = assetPath.match(/([^\/]+\/[^\/]+\.\w+)$/)
+ const matches = assetPath.match(/([^\/\\]+[\/\\][^\/\\]+\.\w+)$/)
if (!matches || !matches[1]) {
throw new Error(`Failed to get example asset path from path: '${assetPath}'.`)
}
- return matches[1]
+ return matches[1].replaceAll('\\', '/')
}
function isAliasedAstroInstance(page: AstroInstance): page is AliasedAstroInstance {
import fs from 'node:fs'
import path from 'node:path'
import { getConfig } from './config'
+import { fileURLToPath } from 'node:url';
// The docs directory path relative to the root of the project.
export const docsDirectory = getConfig().docsDir
for (const docsPath of generatedVersionedDocsPaths) {
const sanitizedDocsPath = sanitizeVersionedDocsPathForValidation(docsPath)
- const absoluteDocsPath = path.join(distUrl.pathname, 'docs', docs_version, sanitizedDocsPath)
+ const absoluteDocsPath = fileURLToPath(new URL(path.join( './docs', docs_version, sanitizedDocsPath), distUrl));
const docsPathExists = fs.existsSync(absoluteDocsPath)