Skip to content

Commit 8797eda

Browse files
authored
Merge pull request #1828 from andybalaam/check-shared-url-immediately
Check that a URL is valid as soon as we load the Add Bookmark dialog
2 parents 460f892 + 3899847 commit 8797eda

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/ui/views/native/AddBookmarkIntent.vue

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export default {
103103
data() {
104104
return {
105105
url: this.$route.params.url,
106-
urlError: null,
106+
urlError: this.checkUrl(this.$route.params.url),
107107
title: this.$route.params.title || '',
108108
temporaryParent: null,
109109
displayFolderChooser: false,
@@ -151,13 +151,7 @@ export default {
151151
this.$store.dispatch(actions.LOAD_TREE, this.id)
152152
},
153153
url() {
154-
this.urlError = null
155-
try {
156-
// eslint-disable-next-line
157-
new URL(this.url)
158-
} catch (e) {
159-
this.urlError = 'Invalid URL'
160-
}
154+
this.urlError = this.checkUrl(this.url)
161155
},
162156
tree() {
163157
const parentFolder = this.tree.findFolder(this.$store.state.lastFolders[this.id]) || this.tree.findFolder(this.tree.id)
@@ -189,6 +183,15 @@ export default {
189183
},
190184
onTriggerFolderChooser() {
191185
this.displayFolderChooser = true
186+
},
187+
checkUrl(url) {
188+
try {
189+
// eslint-disable-next-line
190+
new URL(url)
191+
return null
192+
} catch (e) {
193+
return 'Invalid URL'
194+
}
192195
}
193196
}
194197
}

0 commit comments

Comments
 (0)