diff --git a/src/components/MintSettings.vue b/src/components/MintSettings.vue index ef87cbb5..b9a96467 100644 --- a/src/components/MintSettings.vue +++ b/src/components/MintSettings.vue @@ -106,7 +106,7 @@ rounded dense outlined - @keydown.enter.prevent="showAddMintDialog = true" + @keydown.enter.prevent="sanitizeMintUrlAndShowAddDialog" v-model="addMintData.url" placeholder="https://" ref="mintInput" @@ -133,6 +133,7 @@ rounded dense outlined + @keydown.enter.prevent="sanitizeMintUrlAndShowAddDialog" v-model="addMintData.nickname" label="Nickname (e.g. Testnet)" ref="mintNicknameInput" @@ -147,7 +148,7 @@ color="primary" :disabled="addMintData.url.length == 0" :loading="addMintBlocking" - @click="showAddMintDialog = true" + @click="sanitizeMintUrlAndShowAddDialog" > Add mint @@ -609,6 +610,25 @@ export default defineComponent({ this.editMintData = Object.assign({}, mint); this.showEditMintDialog = true; }, + validateMintUrl: function (url) { + try { + new URL(url); + return true; + } catch (e) { + return false; + } + }, + sanitizeMintUrlAndShowAddDialog: function () { + if (!this.validateMintUrl(this.addMintData.url)) { + notifyError("Invalid URL"); + return; + } + let urlObj = new URL(this.addMintData.url); + urlObj.hostname = urlObj.hostname.toLowerCase(); + this.addMintData.url = urlObj.toString(); + this.addMintData.url = this.addMintData.url.replace(/\/$/, ""); + this.showAddMintDialog = true; + }, addMintInternal: function (mintToAdd, verbose) { this.addingMint = true; try {