fix: Character escaping

pull/67/head
Boaz Poolman 2022-06-14 18:47:28 +02:00
parent 829a50492c
commit a6035e16ae
1 changed files with 4 additions and 8 deletions

View File

@ -25,8 +25,7 @@ module.exports = () => ({
if (shouldExclude) return; if (shouldExclude) return;
// Replace reserved characters in filenames. // Replace reserved characters in filenames.
configName = configName.replace(/:/g, "#"); configName = configName.replace(/:/g, "#").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
@ -61,8 +60,7 @@ module.exports = () => ({
if (shouldExclude) return; if (shouldExclude) return;
// Replace reserved characters in filenames. // Replace reserved characters in filenames.
configName = configName.replace(/:/g, "#"); configName = configName.replace(/:/g, "#").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`);
}, },
@ -76,8 +74,7 @@ module.exports = () => ({
*/ */
readConfigFile: async (configType, configName) => { readConfigFile: async (configType, configName) => {
// Replace reserved characters in filenames. // Replace reserved characters in filenames.
configName = configName.replace(/:/g, "#"); configName = configName.replace(/:/g, "#").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`)
@ -111,8 +108,7 @@ module.exports = () => ({
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. // Put back reserved characters from filenames.
let formattedName = name.replace(/#/g, ":"); const formattedName = name.replace(/#/g, ":").replace(/\$/g, "/");
formattedName = name.replace(/\$/g, "/");
if ( if (
configType && configType !== type configType && configType !== type