Skip to content
Permalink
Browse files

Customizer: Trim whitespace from custom link URLs.

This complements a similar fix for the Menus screen in [45655].

Props donmhico, audrasjb.
Merges [45869] to the 5.2 branch.
Fixes #47888. See #47723.

git-svn-id: https://develop.svn.wordpress.org/branches/5.2@45870 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information...
SergeyBiryukov committed Aug 21, 2019
1 parent 4cfe2ae commit 1f709794ec9a24948fff1d063233092302fd3ede
Showing with 4 additions and 3 deletions.
  1. +1 −1 src/js/_enqueues/lib/nav-menu.js
  2. +3 −2 src/js/_enqueues/wp/customize/nav-menus.js
@@ -944,7 +944,7 @@
},

addCustomLink : function( processMethod ) {
var url = $('#custom-menu-item-url').val(),
var url = $('#custom-menu-item-url').val().trim(),
label = $('#custom-menu-item-name').val();

processMethod = processMethod || api.addMenuItemToBottom;
@@ -544,6 +544,7 @@
var menuItem,
itemName = $( '#custom-menu-item-name' ),
itemUrl = $( '#custom-menu-item-url' ),
url = itemUrl.val().trim(),
urlRegex;

if ( ! this.currentMenuControl ) {
@@ -567,14 +568,14 @@
if ( '' === itemName.val() ) {
itemName.addClass( 'invalid' );
return;
} else if ( ! urlRegex.test( itemUrl.val() ) ) {
} else if ( ! urlRegex.test( url ) ) {
itemUrl.addClass( 'invalid' );
return;
}

menuItem = {
'title': itemName.val(),
'url': itemUrl.val(),
'url': url,
'type': 'custom',
'type_label': api.Menus.data.l10n.custom_label,
'object': 'custom'

0 comments on commit 1f70979

Please sign in to comment.
You can’t perform that action at this time.