- Prepend 'http://' to pasted URLs.
- Do not prepend it when typing an URL.
- Do not prepend it when pasting the same URL for the second time (trying to correct wrong guess).
Props iseulde. Fixes #18149.
Built from https://develop.svn.wordpress.org/trunk@31602


git-svn-id: http://core.svn.wordpress.org/trunk@31583 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2015-03-03 00:01:28 +00:00
parent a9f165915f
commit 1750c89afb
3 changed files with 19 additions and 5 deletions

View File

@ -2,7 +2,7 @@
var wpLink;
( function( $ ) {
var editor, searchTimer, River, Query,
var editor, searchTimer, River, Query, correctedURL,
inputs = {},
rivers = {},
isTouch = ( 'ontouchend' in document );
@ -72,6 +72,17 @@ var wpLink;
wpLink.searchInternalLinks.call( self );
}, 500 );
});
inputs.url.on( 'paste blur', function() {
setTimeout( function() {
var url = $.trim( inputs.url.val() );
if ( url && correctedURL !== url && ! /^(?:[a-z]+:|#|\?|\.|\/)/.test( url ) ) {
inputs.url.val( 'http://' + url );
correctedURL = url;
}
}, 0 );
} );
},
open: function( editorId ) {
@ -183,6 +194,9 @@ var wpLink;
inputs.backdrop.hide();
inputs.wrap.hide();
correctedURL = false;
$( document ).trigger( 'wplink-close', inputs.wrap );
},
@ -211,7 +225,7 @@ var wpLink;
attrs = wpLink.getAttrs();
// If there's no href, return.
if ( ! attrs.href || attrs.href == 'http://' )
if ( ! attrs.href )
return;
// Build HTML
@ -309,7 +323,7 @@ var wpLink;
inputs.url.val( selection.replace( /&|&#0?38;/gi, '&' ) );
} else {
// Set URL to default.
inputs.url.val( 'http://' );
inputs.url.val( '' );
}
// Set description to default.

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-31601';
$wp_version = '4.2-alpha-31602';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.