diff --git a/packages/gatsby/src/utils/node-manifest.ts b/packages/gatsby/src/utils/node-manifest.ts index d21651a73c3f1..c7e2f330665f6 100644 --- a/packages/gatsby/src/utils/node-manifest.ts +++ b/packages/gatsby/src/utils/node-manifest.ts @@ -249,17 +249,24 @@ export async function processNodeManifest( ) /** - * Commas are considered special characters on Windows and are not valid in file paths with the exception of - * the hard disk partition name at the beginning of a file path (i.e. C:). + * Windows has a handful of special/reserved characters that are not valid in a file path + * @reference https://superuser.com/questions/358855/what-characters-are-safe-in-cross-platform-file-names-for-linux-windows-and-os + * + * The two exceptions to the list linked above are + * - the colon that is part of the hard disk partition name at the beginning of a file path (i.e. C:) + * - backslashes. We don't want to replace backslashes because those are used to delineate what the actual file path is * * During local development, node manifests can be written to disk but are generally unused as they are only used - * for Content Sync which runs in Gatsby cloud. Gatsby cloud is a Linux environment in which colons are valid in - * filepaths. To avoid errors on Windows, we replace all ":" instances in the filepath (with the exception of the + * for Content Sync which runs in Gatsby Cloud. Gatsby cloud is a Linux environment in which these special chars are valid in + * filepaths. To avoid errors on Windows, we replace all instances of the special chars in the filepath (with the exception of the * hard disk partition name) with "-" to ensure that local Windows development setups do not break when attempting * to write one of these manifests to disk. */ if (process.platform === `win32`) { - manifestFilePath = manifestFilePath.replace(/(?|\|/g, + `-` + ) } const manifestFileDir = path.dirname(manifestFilePath)