diff --git a/src/wp-admin/js/widgets/media-widgets.js b/src/wp-admin/js/widgets/media-widgets.js
index 598d94d..19af187 100644
a
|
b
|
wp.mediaWidgets = ( function( $ ) { |
146 | 146 | */ |
147 | 147 | fetch: function() { |
148 | 148 | var embedLinkView = this, fetchSuccess, matches, fileExt, urlParser; // eslint-disable-line consistent-this |
| 149 | var url = embedLinkView.model.get( 'url' ); |
149 | 150 | |
150 | 151 | if ( embedLinkView.dfd && 'pending' === embedLinkView.dfd.state() ) { |
151 | 152 | embedLinkView.dfd.abort(); |
152 | 153 | } |
153 | 154 | |
154 | 155 | // Abort if the URL field was emptied out. |
155 | | if ( ! embedLinkView.model.get( 'url' ) ) { |
| 156 | if ( ! url ) { |
156 | 157 | embedLinkView.setErrorNotice( '' ); |
157 | 158 | return; |
158 | 159 | } |
159 | 160 | |
| 161 | // only proceed with embed if the field contains more than 11 characters |
| 162 | // Example: http://a.io is 11 chars |
| 163 | if ( url && ( url.length < 11 || ! url.match(/(http|https):\/\/(\w+:{0,1}\w*)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%!\-\/]))?/) ) ) { |
| 164 | var embedLinkView = this; // eslint-disable-line consistent-this |
| 165 | $( '#embed-url-field' ).addClass( 'invalid' ); |
| 166 | embedLinkView.setAddToWidgetButtonDisabled( true ); |
| 167 | return; |
| 168 | } |
| 169 | |
160 | 170 | fetchSuccess = function( response ) { |
161 | 171 | embedLinkView.renderoEmbed({ |
162 | 172 | data: { |
… |
… |
wp.mediaWidgets = ( function( $ ) { |
170 | 180 | }; |
171 | 181 | |
172 | 182 | urlParser = document.createElement( 'a' ); |
173 | | urlParser.href = embedLinkView.model.get( 'url' ); |
| 183 | urlParser.href = url; |
174 | 184 | matches = urlParser.pathname.toLowerCase().match( /\.(\w+)$/ ); |
175 | 185 | if ( matches ) { |
176 | 186 | fileExt = matches[1]; |
diff --git a/src/wp-includes/js/media-views.js b/src/wp-includes/js/media-views.js
index 29b56c6..c875ad7 100644
a
|
b
|
EmbedLink = wp.media.view.Settings.extend({ |
4614 | 4614 | this.$('.embed-container').hide().find('.embed-preview').empty(); |
4615 | 4615 | this.$( '.setting' ).hide(); |
4616 | 4616 | |
4617 | | // only proceed with embed if the field contains more than 11 characters |
4618 | | // Example: http://a.io is 11 chars |
4619 | | if ( url && ( url.length < 11 || ! url.match(/^http(s)?:\/\//) ) ) { |
| 4617 | // If URL is blank. |
| 4618 | if ( ! url ) { |
4620 | 4619 | return; |
4621 | 4620 | } |
4622 | 4621 | |