Skip to content

Commit

Permalink
Fix embedding Twitter URLs with a trailing slash (Closes WordPress#12664
Browse files Browse the repository at this point in the history
)
  • Loading branch information
gbroques committed Mar 28, 2019
1 parent 95277f6 commit 9f0f0ce
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/block-library/src/embed/edit.js
Expand Up @@ -62,12 +62,19 @@ export function getEmbedEditComponent( title, icon, responsive = true ) {
if ( switchedPreview || switchedURL ) {
if ( this.props.cannotEmbed ) {
// Can't embed this URL, and we've just received or switched the preview.
this.resubmitWithoutTrailingSlash();
return;
}
this.handleIncomingPreview();
}
}

resubmitWithoutTrailingSlash() {
this.setState( ( prevState ) => ( {
url: prevState.url.replace( /\/$/, '' ),
} ), this.setUrl );
}

setUrl( event ) {
if ( event ) {
event.preventDefault();
Expand Down

0 comments on commit 9f0f0ce

Please sign in to comment.