wpLink: fix the logic for prepending http:// and trim the input.

Props iseulde. See #18149.
Built from https://develop.svn.wordpress.org/trunk@31606


git-svn-id: http://core.svn.wordpress.org/trunk@31587 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz
2015-03-03 21:21:25 +00:00
parent b201f3a5cb
commit eecd5561d8
3 changed files with 18 additions and 12 deletions

View File

@@ -73,16 +73,20 @@ var wpLink;
}, 500 );
});
inputs.url.on( 'paste blur', function() {
setTimeout( function() {
var url = $.trim( inputs.url.val() );
function correctURL() {
var url = $.trim( inputs.url.val() );
if ( url && correctedURL !== url && ! /^(?:[a-z]+:|#|\?|\.|\/)/.test( url ) ) {
inputs.url.val( 'http://' + url );
correctedURL = url;
}
}, 0 );
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 ) {
@@ -157,6 +161,8 @@ var wpLink;
if ( ! rivers.recent.ul.children().length ) {
rivers.recent.ajax();
}
correctedURL = inputs.url.val().replace( /^http:\/\//, '' );
},
mceRefresh: function() {
@@ -202,8 +208,8 @@ var wpLink;
getAttrs: function() {
return {
href: inputs.url.val(),
title: inputs.title.val(),
href: $.trim( inputs.url.val() ),
title: $.trim( inputs.title.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.2-alpha-31605';
$wp_version = '4.2-alpha-31606';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.