Revert "feat: Escape '/' with '$' in filenames"

pull/60/head
Boaz Poolman 2022-06-14 18:45:25 +02:00 committed by GitHub
parent 829a50492c
commit 55f34e20ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 10 deletions

View File

@ -28,7 +28,7 @@
"uuid": "2e84e366-1e09-43c2-a99f-a0d0acbc2ca5" "uuid": "2e84e366-1e09-43c2-a99f-a0d0acbc2ca5"
}, },
"engines": { "engines": {
"node": ">=14.x.x <=16.x.x", "node": ">=12.x.x <=16.x.x",
"npm": ">=6.0.0" "npm": ">=6.0.0"
}, },
"license": "MIT" "license": "MIT"

View File

@ -24,9 +24,8 @@ module.exports = () => ({
const shouldExclude = !isEmpty(strapi.config.get('plugin.config-sync.excludedConfig').filter((option) => `${configType}.${configName}`.startsWith(option))); const shouldExclude = !isEmpty(strapi.config.get('plugin.config-sync.excludedConfig').filter((option) => `${configType}.${configName}`.startsWith(option)));
if (shouldExclude) return; if (shouldExclude) return;
// Replace reserved characters in filenames. // Replace ':' with '#' in filenames for Windows support.
configName = configName.replace(/:/g, "#"); configName = configName.replace(/:/g, "#");
configName = configName.replace(/\//g, "$");
// Check if the JSON content should be minified. // Check if the JSON content should be minified.
const json = !strapi.config.get('plugin.config-sync').minify const json = !strapi.config.get('plugin.config-sync').minify
@ -60,9 +59,8 @@ module.exports = () => ({
const shouldExclude = !isEmpty(strapi.config.get('plugin.config-sync.excludedConfig').filter((option) => configName.startsWith(option))); const shouldExclude = !isEmpty(strapi.config.get('plugin.config-sync.excludedConfig').filter((option) => configName.startsWith(option)));
if (shouldExclude) return; if (shouldExclude) return;
// Replace reserved characters in filenames. // Replace ':' with '#' in filenames for Windows support.
configName = configName.replace(/:/g, "#"); configName = configName.replace(/:/g, "#");
configName = configName.replace(/\//g, "$");
fs.unlinkSync(`${strapi.config.get('plugin.config-sync.syncDir')}${configName}.json`); fs.unlinkSync(`${strapi.config.get('plugin.config-sync.syncDir')}${configName}.json`);
}, },
@ -75,9 +73,8 @@ module.exports = () => ({
* @returns {object} The JSON content of the config file. * @returns {object} The JSON content of the config file.
*/ */
readConfigFile: async (configType, configName) => { readConfigFile: async (configType, configName) => {
// Replace reserved characters in filenames. // Replace ':' with '#' in filenames for Windows support.
configName = configName.replace(/:/g, "#"); configName = configName.replace(/:/g, "#");
configName = configName.replace(/\//g, "$");
const readFile = util.promisify(fs.readFile); const readFile = util.promisify(fs.readFile);
return readFile(`${strapi.config.get('plugin.config-sync.syncDir')}${configType}.${configName}.json`) return readFile(`${strapi.config.get('plugin.config-sync.syncDir')}${configType}.${configName}.json`)
@ -110,9 +107,8 @@ module.exports = () => ({
const type = file.split('.')[0]; // Grab the first part of the filename. const type = file.split('.')[0]; // Grab the first part of the filename.
const name = file.split(/\.(.+)/)[1].split('.').slice(0, -1).join('.'); // Grab the rest of the filename minus the file extension. const name = file.split(/\.(.+)/)[1].split('.').slice(0, -1).join('.'); // Grab the rest of the filename minus the file extension.
// Put back reserved characters from filenames. // Replace ':' with '#' in filenames for Windows support.
let formattedName = name.replace(/#/g, ":"); const formattedName = name.replace(/#/g, ":");
formattedName = name.replace(/\$/g, "/");
if ( if (
configType && configType !== type configType && configType !== type