mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-23 22:17:00 +02:00
test: utils for load
This commit is contained in:
parent
d80a2555c0
commit
cfd11fbb6d
2 changed files with 43 additions and 5 deletions
|
@ -31,13 +31,13 @@ function encodePath(userpath) {
|
|||
}
|
||||
|
||||
function fileToComponentName(file) {
|
||||
let str = file.replace(/([A-Z])/g, ' $1');
|
||||
if (str.length === 1) {
|
||||
return str.toUpperCase();
|
||||
}
|
||||
const ext = extRE.exec(file)[1];
|
||||
let str = file.replace(extRE, '');
|
||||
str = str.replace(/([A-Z])/g, ' $1');
|
||||
str = str.replace(/^[\W_]+|[\W_]+$/g, '').toLowerCase();
|
||||
str = str.charAt(0).toUpperCase() + str.slice(1);
|
||||
return str.replace(/[\W_]+(\w|$)/g, (_, ch) => ch.toUpperCase());
|
||||
str = str.replace(/[\W_]+(\w|$)/g, (_, ch) => ch.toUpperCase());
|
||||
return ext ? ext.toUpperCase() + str : str;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue