re-use sanitizeUrl utils method, add / if it's not added already

This commit is contained in:
Maurits Lourens 2021-09-17 11:43:27 +02:00
parent d3f79cf464
commit f9c82e5059
2 changed files with 12 additions and 2 deletions

View File

@ -5,6 +5,7 @@
import { Input, Select, ModalContent, Toggle } from "@budibase/bbui"
import getTemplates from "builderStore/store/screenTemplates"
import analytics from "analytics"
import sanitizeUrl from "builderStore/store/screenTemplates/utils/sanitizeUrl"
const CONTAINER = "@budibase/standard-components/container"
@ -84,7 +85,7 @@
if (!event.detail.startsWith("/")) {
route = "/" + event.detail
}
route = route.replace(/ +/g, "-")
route = sanitizeUrl(route)
}
</script>

View File

@ -7,13 +7,17 @@
import RoleSelect from "./PropertyControls/RoleSelect.svelte"
import { currentAsset, store } from "builderStore"
import { FrontendTypes } from "constants"
import sanitizeUrl from "builderStore/store/screenTemplates/utils/sanitizeUrl"
export let componentInstance
export let bindings
function setAssetProps(name, value, parser) {
if (parser && typeof parser === "function") {
console.log("before", value)
value = parser(value)
console.log("after", value)
console.log("deepGet", deepGet($currentAsset, name))
}
const selectedAsset = get(currentAsset)
@ -37,7 +41,12 @@
key: "routing.route",
label: "Route",
control: Input,
parser: val => val.replace(/ +/g, "-"),
parser: val => {
if (!val.startsWith("/")) {
val = "/" + val
}
return sanitizeUrl(val)
},
},
{ key: "routing.roleId", label: "Access", control: RoleSelect },
{ key: "layoutId", label: "Layout", control: LayoutSelect },