diff --git a/assets/js/components/Config/FormRow.vue b/assets/js/components/Config/FormRow.vue index 40fa4d500..2965842f9 100644 --- a/assets/js/components/Config/FormRow.vue +++ b/assets/js/components/Config/FormRow.vue @@ -16,6 +16,9 @@
{{ error }}
+
+ {{ warning }} +
{{ $t("config.form.example") }}: {{ example }} @@ -47,6 +50,7 @@ export default { optional: Boolean, deprecated: Boolean, error: String, + warning: String, danger: String, example: String, docsLink: String, diff --git a/assets/js/components/Config/NetworkModal.vue b/assets/js/components/Config/NetworkModal.vue index 551f0c462..2b9ed6644 100644 --- a/assets/js/components/Config/NetworkModal.vue +++ b/assets/js/components/Config/NetworkModal.vue @@ -43,6 +43,7 @@ id="networkExternalUrl" :label="$t('config.network.labelExternalUrl')" :help="$t('config.network.descriptionExternalUrl')" + :warning="urlPathWarning(values.externalUrl)" example="https://evcc.example.org" optional > @@ -83,6 +84,16 @@ export default { components: { FormRow, JsonModal }, emits: ["changed"], methods: { + urlPathWarning(url) { + try { + if (new URL(url).pathname > "/") { + return this.$t("config.network.warningUrlPath"); + } + } catch { + // ignore + } + return null; + }, transformWriteValues(values) { const payload = { ...values }; delete payload.internalUrl; diff --git a/i18n/de.json b/i18n/de.json index a90addff5..f334bba0a 100644 --- a/i18n/de.json +++ b/i18n/de.json @@ -568,7 +568,8 @@ "labelHost": "mDNS-Hostname", "labelInternalUrl": "Interne URL", "labelPort": "Port", - "title": "Netzwerk" + "title": "Netzwerk", + "warningUrlPath": "Die URL benötigt normalerweise keinen Pfad. Bist du dir sicher?" }, "ocpp": { "connectedChargers": "Verbundene Wallboxen", diff --git a/i18n/en.json b/i18n/en.json index 86d8dc7dc..7f57af90e 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -568,7 +568,8 @@ "labelHost": "mDNS Hostname", "labelInternalUrl": "Internal URL", "labelPort": "Port", - "title": "Network" + "title": "Network", + "warningUrlPath": "The URL usually doesn't need a path. Are you sure this is correct?" }, "ocpp": { "connectedChargers": "Connected chargers", diff --git a/tests/config.spec.ts b/tests/config.spec.ts index 2295abe7c..af87cea01 100644 --- a/tests/config.spec.ts +++ b/tests/config.spec.ts @@ -102,7 +102,10 @@ test.describe("network modal", async () => { await expectModalVisible(modal); const portValue = await modal.getByLabel("Port").inputValue(); + await modal.getByLabel("External URL").fill(NETWORK_EXTERNAL_URL + "/somepath"); + await expect(modal.getByRole("status")).toContainText("doesn't need a path"); await modal.getByLabel("External URL").fill(NETWORK_EXTERNAL_URL); + await expect(modal.getByRole("status")).not.toBeVisible(); await modal.getByLabel("mDNS Hostname").fill(NETWORK_HOST); await modal.getByRole("button", { name: "Save" }).click();