wpLink: support whole URLs including query/fragment when pre-filling the URL field. Fixes #19992

git-svn-id: https://develop.svn.wordpress.org/trunk@28828 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2014-06-25 00:36:24 +00:00
parent ccdfdb2c8e
commit 7a2d51e539

View File

@ -270,14 +270,14 @@ var wpLink;
setDefaultValues: function() {
var selection = editor && editor.selection.getContent(),
emailRegexp = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i,
urlRegexp = /^(https?|ftp):\/\/[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
urlRegexp = /^(https?|ftp):\/\/[A-Z0-9.-]+\.[A-Z]{2,4}[^ "]*$/i;
if ( selection && emailRegexp.test( selection ) ) {
// Selection is email address
inputs.url.val( 'mailto:' + selection );
} else if ( selection && urlRegexp.test( selection ) ) {
// Selection is URL
inputs.url.val( selection );
inputs.url.val( selection.replace( /&|&#0?38;/gi, '&' ) );
} else {
// Set URL to default.
inputs.url.val( 'http://' );