wpLink: always attempt to correct the URL before getting the URL field value. Fixes an edge case where the URL was not corrected when the user submitted the form by pressing Enter.

Props andfinally. Fixes #32412.
Built from https://develop.svn.wordpress.org/trunk@32992


git-svn-id: http://core.svn.wordpress.org/trunk@32963 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2015-06-28 23:07:25 +00:00
parent 83e33a2ca0
commit 4605417b1c
3 changed files with 16 additions and 13 deletions

View File

@ -77,20 +77,21 @@ var wpLink;
}, 500 );
});
function correctURL() {
inputs.url.on( 'paste', function() {
setTimeout( wpLink.correctURL, 0 );
} );
inputs.url.on( 'blur', wpLink.correctURL );
},
// If URL wasn't corrected last time and doesn't start with http:, https:, ? # or /, prepend http://
correctURL: function () {
var url = $.trim( inputs.url.val() );
if ( url && correctedURL !== url && ! /^(?:[a-z]+:|#|\?|\.|\/)/.test( url ) ) {
inputs.url.val( 'http://' + url );
correctedURL = url;
}
}
inputs.url.on( 'paste', function() {
setTimeout( correctURL, 0 );
} );
inputs.url.on( 'blur', correctURL );
},
open: function( editorId ) {
@ -267,6 +268,8 @@ var wpLink;
},
getAttrs: function() {
wpLink.correctURL();
return {
href: $.trim( inputs.url.val() ),
target: inputs.openInNewTab.prop( 'checked' ) ? '_blank' : ''

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.3-alpha-32991';
$wp_version = '4.3-alpha-32992';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.