Skip to content

Commit

Permalink
Merge pull request #1828 from andybalaam/check-shared-url-immediately
Browse files Browse the repository at this point in the history
Check that a URL is valid as soon as we load the Add Bookmark dialog
  • Loading branch information
marcelklehr authored Jan 15, 2025
2 parents 460f892 + 3899847 commit 8797eda
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/ui/views/native/AddBookmarkIntent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export default {
data() {
return {
url: this.$route.params.url,
urlError: null,
urlError: this.checkUrl(this.$route.params.url),
title: this.$route.params.title || '',
temporaryParent: null,
displayFolderChooser: false,
Expand Down Expand Up @@ -151,13 +151,7 @@ export default {
this.$store.dispatch(actions.LOAD_TREE, this.id)
},
url() {
this.urlError = null
try {
// eslint-disable-next-line
new URL(this.url)
} catch (e) {
this.urlError = 'Invalid URL'
}
this.urlError = this.checkUrl(this.url)
},
tree() {
const parentFolder = this.tree.findFolder(this.$store.state.lastFolders[this.id]) || this.tree.findFolder(this.tree.id)
Expand Down Expand Up @@ -189,6 +183,15 @@ export default {
},
onTriggerFolderChooser() {
this.displayFolderChooser = true
},
checkUrl(url) {
try {
// eslint-disable-next-line
new URL(url)
return null
} catch (e) {
return 'Invalid URL'
}
}
}
}
Expand Down

0 comments on commit 8797eda

Please sign in to comment.