File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed
html_builder/static/src/website_preview
html_editor/static/src/main/link Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -309,7 +309,14 @@ export class WebsiteBuilder extends Component {
309
309
if ( href && target !== "_blank" && ! this . state . isEditing ) {
310
310
if ( isTopWindowURL ( linkEl ) ) {
311
311
ev . preventDefault ( ) ;
312
- browser . location . assign ( href ) ;
312
+ try {
313
+ browser . location . assign ( href ) ;
314
+ } catch {
315
+ this . notification . add ( _t ( "%s is not a valid URL." , href ) , {
316
+ title : _t ( "Invalid URL" ) ,
317
+ type : "danger" ,
318
+ } ) ;
319
+ }
313
320
} else if (
314
321
this . websiteContent . el . contentWindow . location . pathname !==
315
322
new URL ( href ) . pathname
Original file line number Diff line number Diff line change @@ -194,6 +194,9 @@ export class LinkPopover extends Component {
194
194
) {
195
195
url = "https://" + url ;
196
196
}
197
+ if ( url && ( url . startsWith ( "http:" ) || url . startsWith ( "https:" ) ) ) {
198
+ url = URL . parse ( url ) ? url : "" ;
199
+ }
197
200
return url ;
198
201
}
199
202
deduceUrl ( text ) {
@@ -228,7 +231,6 @@ export class LinkPopover extends Component {
228
231
this . state . previewIcon = { type : "mimetype" , value : mimetype } ;
229
232
return ;
230
233
}
231
-
232
234
try {
233
235
url = new URL ( this . state . url ) ; // relative to absolute
234
236
} catch {
You can’t perform that action at this time.
0 commit comments