{"record":{"id":"179b1381edceb2f3","repo":"facebook/docusaurus","slug":"extension-ext-contains-a-slash-which-is","errorCode":null,"errorMessage":"Extension \"${ext}\" contains a \"/\" (slash) which is not allowed.\nIf the redirect extension system is not good enough for your use case, you can create redirects yourself with the \"createRedirects\" plugin option.","messagePattern":"Extension \"(.+?)\" contains a \"/\" \\(slash\\) which is not allowed\\.\nIf the redirect extension system is not good enough for your use case, you can create redirects yourself with the \"createRedirects\" plugin option\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/docusaurus-plugin-client-redirects/src/extensionRedirects.ts","lineNumber":30,"sourceCode":"} from '@docusaurus/utils-common';\nimport type {RedirectItem} from './types';\n\nconst ExtensionAdditionalMessage =\n  'If the redirect extension system is not good enough for your use case, you can create redirects yourself with the \"createRedirects\" plugin option.';\n\nconst validateExtension = (ext: string) => {\n  if (!ext) {\n    throw new Error(\n      `Extension \"${ext}\" is not allowed.\\n${ExtensionAdditionalMessage}`,\n    );\n  }\n  if (ext.includes('.')) {\n    throw new Error(\n      `Extension \"${ext}\" contains a \".\" (dot) which is not allowed.\\n${ExtensionAdditionalMessage}`,\n    );\n  }\n  if (ext.includes('/')) {\n    throw new Error(\n      `Extension \"${ext}\" contains a \"/\" (slash) which is not allowed.\\n${ExtensionAdditionalMessage}`,\n    );\n  }\n  if (encodeURIComponent(ext) !== ext) {\n    throw new Error(\n      `Extension \"${ext}\" contains invalid URI characters.\\n${ExtensionAdditionalMessage}`,\n    );\n  }\n};\n\nconst addLeadingDot = (extension: string) => `.${extension}`;\n\n/**\n * Create new `/path` that redirects to existing an `/path.html`\n */\nexport function createToExtensionsRedirects(\n  paths: string[],\n  extensions: string[],","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/facebook/docusaurus/blob/3f483e80e326cc646b54b83d564b3f0c4881b9a6/packages/docusaurus-plugin-client-redirects/src/extensionRedirects.ts#L12-L48","documentation":"Thrown by validateExtension() when an extension string in fromExtensions/toExtensions contains a '/' character. Extensions must be flat tokens; a slash would turn the extension into a path segment and produce redirect paths that cross directories, which the plugin forbids.","triggerScenarios":"Configuring fromExtensions: ['html/v2'] or toExtensions: ['a/b']; passing a path fragment instead of a bare extension. Reached in the same forEach(validateExtension) loop.","commonSituations":"Mistakenly passing a relative path or a versioned folder fragment as an extension; building the array by splitting a pathname on '.' and keeping a segment that contains '/'.","solutions":["Use a bare extension with no slash: 'html' instead of 'html/v2'.","If you need path-level redirects, use the createRedirects option instead of fromExtensions/toExtensions.","Sanitize generated arrays: ext.replaceAll('/', '')."],"exampleFix":"// before\ntoExtensions: ['html/v2'],\n// after\ntoExtensions: ['html'],","handlingStrategy":"validation","validationCode":"function assertNoSlash(ext: string): void {\n  if (ext.includes('/')) {\n    throw new Error(`Extension \"${ext}\" contains a \"/\" which is not allowed.`);\n  }\n}","typeGuard":"const isFlatExtension = (e: unknown): e is string =>\n  typeof e === 'string' && !!e && !e.includes('/') && !e.includes('.')\n  && encodeURIComponent(e) === e;","tryCatchPattern":null,"preventionTips":["Use bare tokens only ('html'); never path fragments.","For path-level redirects, use createRedirects instead of extensions.","Lint the extensions array to reject any value containing '/'."],"tags":["plugin-client-redirects","redirects","extensions","validation"],"backgroundTag":null,"analyzedSha":"3f483e80e326cc646b54b83d564b3f0c4881b9a6","analyzedAt":"2026-08-12T13:25:04.382Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}