mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-24 06:27:02 +02:00
fix(v2): windows compatibility (#1353)
This commit is contained in:
parent
15bc33df50
commit
5872e2dd91
4 changed files with 37 additions and 3 deletions
|
@ -49,6 +49,21 @@ function fileToComponentName(file) {
|
|||
return ext ? ext.toUpperCase() + str : str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert Windows backslash paths to posix style paths. E.g: endi\\lie -> endi/lie
|
||||
* @param {string} str windows backslash paths
|
||||
* @returns {string} posix-style path
|
||||
*/
|
||||
function posixPath(str) {
|
||||
const isExtendedLengthPath = /^\\\\\?\\/.test(str);
|
||||
const hasNonAscii = /[^\u0000-\u0080]+/.test(str); // eslint-disable-line
|
||||
|
||||
if (isExtendedLengthPath || hasNonAscii) {
|
||||
return str;
|
||||
}
|
||||
return str.replace(/\\/g, '/');
|
||||
}
|
||||
|
||||
function generateChunkName(str, prefix) {
|
||||
const name = str === '/' ? 'index' : kebabHash(str);
|
||||
return prefix ? `${prefix}---${name}` : name;
|
||||
|
@ -153,4 +168,5 @@ module.exports = {
|
|||
idx,
|
||||
normalizeUrl,
|
||||
parse,
|
||||
posixPath,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue