Skip to content

Commit

Permalink
Correct URL basename in EmbedPreview of Embed block
Browse files Browse the repository at this point in the history
  • Loading branch information
dhananjaykuber committed Jul 2, 2024
1 parent 1eab7a2 commit 7786664
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
9 changes: 3 additions & 6 deletions packages/block-library/src/embed/embed-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,11 @@ class EmbedPreview extends Component {
const { interactive } = this.state;

const html = 'photo' === type ? getPhotoHtml( preview ) : preview.html;
const parsedHost = new URL( url ).host.split( '.' );
const parsedHostBaseUrl = parsedHost
.splice( parsedHost.length - 2, parsedHost.length - 1 )
.join( '.' );
const embedSourceUrl = new URL( url ).hostname;
const iframeTitle = sprintf(
// translators: %s: host providing embed content e.g: www.youtube.com
__( 'Embedded content from %s' ),
parsedHostBaseUrl
embedSourceUrl
);
const sandboxClassnames = clsx(
type,
Expand Down Expand Up @@ -136,7 +133,7 @@ class EmbedPreview extends Component {
__(
"Embedded content from %s can't be previewed in the editor."
),
parsedHostBaseUrl
embedSourceUrl
) }
</p>
</Placeholder>
Expand Down
7 changes: 2 additions & 5 deletions packages/block-library/src/embed/embed-preview.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,11 @@ const EmbedPreview = ( {

const { provider_url: providerUrl } = preview;
const html = 'photo' === type ? getPhotoHtml( preview ) : preview.html;
const parsedHost = new URL( url ).host.split( '.' );
const parsedHostBaseUrl = parsedHost
.splice( parsedHost.length - 2, parsedHost.length - 1 )
.join( '.' );
const embedSourceUrl = new URL( url ).host.split( '.' );
const iframeTitle = sprintf(
// translators: %s: host providing embed content e.g: www.youtube.com
__( 'Embedded content from %s' ),
parsedHostBaseUrl
embedSourceUrl
);
const sandboxClassnames = clsx(
type,
Expand Down

0 comments on commit 7786664

Please sign in to comment.