Fixed issues with same URL in appcreator - now allowing it with replacements

This commit is contained in:
frikky
2022-01-13 19:04:39 +01:00
parent ff4f4d6722
commit 7ce0559448
3 changed files with 28 additions and 5 deletions
+25 -2
View File
@@ -322,7 +322,7 @@ const AppCreator = (defaultprops) => {
const [currentActionMethod, setCurrentActionMethod] = useState(
actionNonBodyRequest[0]
);
)
const [currentAction, setCurrentAction] = useState({
name: "",
file_field: "",
@@ -1551,6 +1551,7 @@ const AppCreator = (defaultprops) => {
};
// Saving the app that's been configured.
// Save SAVE app
const submitApp = () => {
alert.info("Uploading and building app " + name);
setAppBuilding(true);
@@ -1608,8 +1609,9 @@ const AppCreator = (defaultprops) => {
}
// Handles actions
var handledPaths = []
for (var key in actions) {
var item = actions[key];
var item = JSON.parse(JSON.stringify(actions[key]))
if (item.errors.length > 0) {
alert.error("Saving with error in action " + item.name);
}
@@ -1618,6 +1620,27 @@ const AppCreator = (defaultprops) => {
item.name = item.description;
}
// Basic way to allow multiple of the same path
var pathjoin = item.url+"_"+item.method.toLowerCase()
if (handledPaths.includes(pathjoin)) {
console.log("ALREADY INCLUDED: ", pathjoin)
// Max 100 of same lol
for (var i = 0; i < 100; i++) {
item.url = item.url+"_shuffle_replace_"+i
pathjoin = item.url+"_"+item.method.toLowerCase()
if (handledPaths.includes(pathjoin)) {
continue
}
console.log("FOUND NEW: ", item.url)
break
}
}
handledPaths.push(pathjoin)
if (data.paths[item.url] === null || data.paths[item.url] === undefined) {
data.paths[item.url] = {};
}