New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report error when URLs can't be embedded and don't generate a fallback #10407

Merged
merged 1 commit into from Oct 10, 2018

Conversation

Projects
None yet
5 participants
@notnownikki
Member

notnownikki commented Oct 8, 2018

Description

Trying to embed some WordPress URLs that can't be embedded will result in a blank preview, rather than an error saying that the URL couldn't be embedded.

This is because oEmbed sometimes doesn't do maybe_make_link and returns a response with a data.status of 404 instead.

This change accounts for that.

How has this been tested?

Try to embed https://wordpress.org/gutenberg/handbook/
You should see the error saying that it can't be embedded.

Types of changes

Bug fix

@notnownikki notnownikki requested a review from WordPress/gutenberg-core Oct 8, 2018

@notnownikki notnownikki modified the milestones: 4.0, 4.1 Oct 8, 2018

@talldan

talldan approved these changes Oct 10, 2018 edited

This looks good and works a charm!

The only nitpick I'd have is that there a mixing of types (preview can be a boolean or an object, cannotEmbed can be a string or a boolean), which could cause some issues down the line if someone else tries to use those variables thinking they're one type when they're another. I think we've had this bite us when trying to optionally set attributes on elements.

@notnownikki notnownikki merged commit 49f8f2b into master Oct 10, 2018

2 checks passed

codecov/project 49.31% (+<.01%) compared to 69ced17
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@youknowriad youknowriad deleted the fix/wordpress-urls-that-dont-get-fallback branch Oct 10, 2018

@gziolo gziolo modified the milestones: 4.1, 4.0 Oct 10, 2018

@mtias mtias added the [Block] Embed label Oct 10, 2018

@@ -412,8 +414,12 @@ function getEmbedBlockSettings( { title, description, icon, category = 'embed',
const preview = url && getEmbedPreview( url );
const previewIsFallback = url && isPreviewEmbedFallback( url );
const fetching = undefined !== url && isRequestingEmbedPreview( url );
// Some WordPress URLs that can't be embedded will cause the API to return

This comment has been minimized.

@aduth

aduth Oct 10, 2018

Member

Should this be normalized at the REST API / data store, rather than delegating the responsibility to the consuming UI component to handle ?

@aduth

aduth Oct 10, 2018

Member

Should this be normalized at the REST API / data store, rather than delegating the responsibility to the consuming UI component to handle ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment