mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 09:37:42 +01:00
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:
parent
83e33a2ca0
commit
4605417b1c
@ -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' : ''
|
||||
|
2
wp-includes/js/wplink.min.js
vendored
2
wp-includes/js/wplink.min.js
vendored
File diff suppressed because one or more lines are too long
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user