diff --git src/wp-admin/js/customize-nav-menus.js src/wp-admin/js/customize-nav-menus.js
index 3e223825c4..0818079656 100644
|
|
|
537 | 537 | var menuItem, |
538 | 538 | itemName = $( '#custom-menu-item-name' ), |
539 | 539 | itemUrl = $( '#custom-menu-item-url' ), |
540 | | urlRegex, |
541 | | urlValue; |
| 540 | urlRegex; |
542 | 541 | |
543 | 542 | if ( ! this.currentMenuControl ) { |
544 | 543 | return; |
545 | 544 | } |
546 | 545 | |
547 | 546 | /* |
548 | | * Copyright (c) 2010-2013 Diego Perini, MIT licensed |
549 | | * https://gist.github.com/dperini/729294 |
550 | | * see also https://mathiasbynens.be/demo/url-regex |
551 | | * modified to allow protocol-relative URLs |
| 547 | * Allow URLs including: |
| 548 | * - http://example.com/ |
| 549 | * - //example.com |
| 550 | * - /directory/ |
| 551 | * - ?query-param |
| 552 | * - #target |
| 553 | * - mailto:foo@example.com |
| 554 | * |
| 555 | * Any further validation will be handled on the server when the setting is attempted to be saved, |
| 556 | * so this pattern does not need to be complete. |
552 | 557 | */ |
553 | | urlRegex = /^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})).?)(?::\d{2,5})?(?:[/?#]\S*)?$/i; |
| 558 | urlRegex = /^((\w+:)?\/\/\w.*|\w+:(?!\/\/$)|\/|\?|#)/; |
554 | 559 | |
555 | | urlValue = itemUrl.val(); |
556 | 560 | if ( '' === itemName.val() ) { |
557 | 561 | itemName.addClass( 'invalid' ); |
558 | 562 | return; |
559 | | } else if ( '' === urlValue || 'http://' === urlValue || ! ( '/' === urlValue[0] || urlRegex.test( urlValue ) ) ) { |
| 563 | } else if ( ! urlRegex.test( itemUrl.val() ) ) { |
560 | 564 | itemUrl.addClass( 'invalid' ); |
561 | 565 | return; |
562 | 566 | } |
563 | 567 | |
564 | 568 | menuItem = { |
565 | 569 | 'title': itemName.val(), |
566 | | 'url': urlValue, |
| 570 | 'url': itemUrl.val(), |
567 | 571 | 'type': 'custom', |
568 | 572 | 'type_label': api.Menus.data.l10n.custom_label, |
569 | 573 | 'object': 'custom' |