Skip to content

Commit

Permalink
Prevent prependHttp from failing if url is not defined (#17928)
Browse files Browse the repository at this point in the history
* Check that url is defined before passing into prependHttp

* Shift check from component to url lib
  • Loading branch information
glendaviesnz authored and gziolo committed Oct 16, 2019
1 parent d7cd263 commit 9515a53
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/url/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,10 @@ export function removeQueryArgs( url, ...args ) {
* @return {string} The updated URL.
*/
export function prependHTTP( url ) {
if ( ! url ) {
return url;
}

url = url.trim();
if ( ! USABLE_HREF_REGEXP.test( url ) && ! EMAIL_REGEXP.test( url ) ) {
return 'http://' + url;
Expand Down

0 comments on commit 9515a53

Please sign in to comment.