]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Docs: fix local assets path handling for Windows compatibility (#41485)
authorLouis-Maxime Piton <louismaxime.piton@orange.com>
Sun, 25 May 2025 12:20:20 +0000 (14:20 +0200)
committerGitHub <noreply@github.com>
Sun, 25 May 2025 12:20:20 +0000 (14:20 +0200)
Co-authored-by: Julien Déramond <juderamond@gmail.com>
site/src/libs/examples.ts
site/src/libs/path.ts

index b85cf5c56f5be9205ae845eda138336933f8b743..15596cd1608cf6c79e31faa26a1d59f8934daff2 100644 (file)
@@ -58,13 +58,13 @@ function getExamplesAssetsRecursively(source: string, assets: string[] = []) {
 }
 
 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 {
index ddcee5954abb1858baa93497433aab23f541511b..a6ff100d519f8dd46ff03292ea55d16ed8428ada 100644 (file)
@@ -1,6 +1,7 @@
 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
@@ -32,7 +33,7 @@ export function validateVersionedDocsPaths(distUrl: URL) {
 
   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)