Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@wordpress/url

Package Overview
Dependencies
Maintainers
12
Versions
177
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wordpress/url - npm Package Compare versions

Comparing version 2.7.0 to 2.8.0

46

build-module/index.js

@@ -9,2 +9,10 @@ /**

/**
* @typedef {{[key: string]: QueryArgParsed}} QueryArgObject
*/
/**
* @typedef {string|string[]|QueryArgObject} QueryArgParsed
*/
/**
* Determines whether the given string looks like a URL.

@@ -52,3 +60,3 @@ *

*
* @return {?string} The protocol part of the URL.
* @return {string|void} The protocol part of the URL.
*/

@@ -95,3 +103,3 @@

*
* @return {?string} The authority part of the URL.
* @return {string|void} The authority part of the URL.
*/

@@ -138,3 +146,3 @@

*
* @return {?string} The path part of the URL.
* @return {string|void} The path part of the URL.
*/

@@ -181,3 +189,3 @@

*
* @return {?string} The query string part of the URL.
* @return {string|void} The query string part of the URL.
*/

@@ -224,3 +232,3 @@

*
* @return {?string} The fragment part of the URL.
* @return {string|void} The fragment part of the URL.
*/

@@ -261,5 +269,5 @@

*
* @param {?string} url URL to which arguments should be appended. If omitted,
* only the resulting querystring is returned.
* @param {Object} args Query arguments to apply to URL.
* @param {string} [url=''] URL to which arguments should be appended. If omitted,
* only the resulting querystring is returned.
* @param {Object} args Query arguments to apply to URL.
*

@@ -299,4 +307,4 @@ * @example

*
* @param {string} url URL
* @param {string} arg Query arg name
* @param {string} url URL.
* @param {string} arg Query arg name.
*

@@ -308,3 +316,3 @@ * @example

*
* @return {Array|string} Query arg value.
* @return {QueryArgParsed|undefined} Query arg value.
*/

@@ -320,4 +328,4 @@

*
* @param {string} url URL
* @param {string} arg Query arg name
* @param {string} url URL.
* @param {string} arg Query arg name.
*

@@ -338,4 +346,4 @@ * @example

*
* @param {string} url URL
* @param {...string} args Query Args
* @param {string} url URL.
* @param {...string} args Query Args.
*

@@ -347,3 +355,3 @@ * @example

*
* @return {string} Updated URL
* @return {string} Updated URL.
*/

@@ -368,3 +376,3 @@

*
* @param {string} url The URL to test
* @param {string} url The URL to test.
*

@@ -376,6 +384,8 @@ * @example

*
* @return {string} The updated URL
* @return {string} The updated URL.
*/
export function prependHTTP(url) {
url = url.trim();
if (!USABLE_HREF_REGEXP.test(url) && !EMAIL_REGEXP.test(url)) {

@@ -382,0 +392,0 @@ return 'http://' + url;

@@ -36,2 +36,10 @@ "use strict";

/**
* @typedef {{[key: string]: QueryArgParsed}} QueryArgObject
*/
/**
* @typedef {string|string[]|QueryArgObject} QueryArgParsed
*/
/**
* Determines whether the given string looks like a URL.

@@ -80,3 +88,3 @@ *

*
* @return {?string} The protocol part of the URL.
* @return {string|void} The protocol part of the URL.
*/

@@ -125,3 +133,3 @@

*
* @return {?string} The authority part of the URL.
* @return {string|void} The authority part of the URL.
*/

@@ -170,3 +178,3 @@

*
* @return {?string} The path part of the URL.
* @return {string|void} The path part of the URL.
*/

@@ -215,3 +223,3 @@

*
* @return {?string} The query string part of the URL.
* @return {string|void} The query string part of the URL.
*/

@@ -260,3 +268,3 @@

*
* @return {?string} The fragment part of the URL.
* @return {string|void} The fragment part of the URL.
*/

@@ -299,5 +307,5 @@

*
* @param {?string} url URL to which arguments should be appended. If omitted,
* only the resulting querystring is returned.
* @param {Object} args Query arguments to apply to URL.
* @param {string} [url=''] URL to which arguments should be appended. If omitted,
* only the resulting querystring is returned.
* @param {Object} args Query arguments to apply to URL.
*

@@ -338,4 +346,4 @@ * @example

*
* @param {string} url URL
* @param {string} arg Query arg name
* @param {string} url URL.
* @param {string} arg Query arg name.
*

@@ -347,3 +355,3 @@ * @example

*
* @return {Array|string} Query arg value.
* @return {QueryArgParsed|undefined} Query arg value.
*/

@@ -360,4 +368,4 @@

*
* @param {string} url URL
* @param {string} arg Query arg name
* @param {string} url URL.
* @param {string} arg Query arg name.
*

@@ -379,4 +387,4 @@ * @example

*
* @param {string} url URL
* @param {...string} args Query Args
* @param {string} url URL.
* @param {...string} args Query Args.
*

@@ -388,3 +396,3 @@ * @example

*
* @return {string} Updated URL
* @return {string} Updated URL.
*/

@@ -410,3 +418,3 @@

*
* @param {string} url The URL to test
* @param {string} url The URL to test.
*

@@ -418,3 +426,3 @@ * @example

*
* @return {string} The updated URL
* @return {string} The updated URL.
*/

@@ -424,2 +432,4 @@

function prependHTTP(url) {
url = url.trim();
if (!USABLE_HREF_REGEXP.test(url) && !EMAIL_REGEXP.test(url)) {

@@ -426,0 +436,0 @@ return 'http://' + url;

{
"name": "@wordpress/url",
"version": "2.7.0",
"version": "2.8.0",
"description": "WordPress URL utilities.",

@@ -30,3 +30,3 @@ "author": "The WordPress Contributors",

},
"gitHead": "2080b50d4a41c9f746485519d1dc368dd9d9354d"
"gitHead": "4fd00581206f63b1854962e9aa23afded445b7ee"
}

@@ -33,3 +33,3 @@ # URL

- _url_ `?string`: URL to which arguments should be appended. If omitted, only the resulting querystring is returned.
- _url_ `[string]`: URL to which arguments should be appended. If omitted, only the resulting querystring is returned.
- _args_ `Object`: Query arguments to apply to URL.

@@ -76,3 +76,3 @@

- `?string`: The authority part of the URL.
- `(string|void)`: The authority part of the URL.

@@ -96,3 +96,3 @@ <a name="getFragment" href="#getFragment">#</a> **getFragment**

- `?string`: The fragment part of the URL.
- `(string|void)`: The fragment part of the URL.

@@ -116,3 +116,3 @@ <a name="getPath" href="#getPath">#</a> **getPath**

- `?string`: The path part of the URL.
- `(string|void)`: The path part of the URL.

@@ -136,3 +136,3 @@ <a name="getProtocol" href="#getProtocol">#</a> **getProtocol**

- `?string`: The protocol part of the URL.
- `(string|void)`: The protocol part of the URL.

@@ -151,8 +151,8 @@ <a name="getQueryArg" href="#getQueryArg">#</a> **getQueryArg**

- _url_ `string`: URL
- _arg_ `string`: Query arg name
- _url_ `string`: URL.
- _arg_ `string`: Query arg name.
_Returns_
- `(Array|string)`: Query arg value.
- `(QueryArgParsed|undefined)`: Query arg value.

@@ -176,3 +176,3 @@ <a name="getQueryString" href="#getQueryString">#</a> **getQueryString**

- `?string`: The query string part of the URL.
- `(string|void)`: The query string part of the URL.

@@ -191,4 +191,4 @@ <a name="hasQueryArg" href="#hasQueryArg">#</a> **hasQueryArg**

- _url_ `string`: URL
- _arg_ `string`: Query arg name
- _url_ `string`: URL.
- _arg_ `string`: Query arg name.

@@ -342,7 +342,7 @@ _Returns_

- _url_ `string`: The URL to test
- _url_ `string`: The URL to test.
_Returns_
- `string`: The updated URL
- `string`: The updated URL.

@@ -361,8 +361,8 @@ <a name="removeQueryArgs" href="#removeQueryArgs">#</a> **removeQueryArgs**

- _url_ `string`: URL
- _args_ `...string`: Query Args
- _url_ `string`: URL.
- _args_ `...string`: Query Args.
_Returns_
- `string`: Updated URL
- `string`: Updated URL.

@@ -369,0 +369,0 @@ <a name="safeDecodeURI" href="#safeDecodeURI">#</a> **safeDecodeURI**

@@ -11,2 +11,10 @@ /**

/**
* @typedef {{[key: string]: QueryArgParsed}} QueryArgObject
*/
/**
* @typedef {string|string[]|QueryArgObject} QueryArgParsed
*/
/**
* Determines whether the given string looks like a URL.

@@ -54,3 +62,3 @@ *

*
* @return {?string} The protocol part of the URL.
* @return {string|void} The protocol part of the URL.
*/

@@ -95,3 +103,3 @@ export function getProtocol( url ) {

*
* @return {?string} The authority part of the URL.
* @return {string|void} The authority part of the URL.
*/

@@ -136,3 +144,3 @@ export function getAuthority( url ) {

*
* @return {?string} The path part of the URL.
* @return {string|void} The path part of the URL.
*/

@@ -177,3 +185,3 @@ export function getPath( url ) {

*
* @return {?string} The query string part of the URL.
* @return {string|void} The query string part of the URL.
*/

@@ -218,3 +226,3 @@ export function getQueryString( url ) {

*
* @return {?string} The fragment part of the URL.
* @return {string|void} The fragment part of the URL.
*/

@@ -253,5 +261,5 @@ export function getFragment( url ) {

*
* @param {?string} url URL to which arguments should be appended. If omitted,
* only the resulting querystring is returned.
* @param {Object} args Query arguments to apply to URL.
* @param {string} [url=''] URL to which arguments should be appended. If omitted,
* only the resulting querystring is returned.
* @param {Object} args Query arguments to apply to URL.
*

@@ -292,4 +300,4 @@ * @example

*
* @param {string} url URL
* @param {string} arg Query arg name
* @param {string} url URL.
* @param {string} arg Query arg name.
*

@@ -301,3 +309,3 @@ * @example

*
* @return {Array|string} Query arg value.
* @return {QueryArgParsed|undefined} Query arg value.
*/

@@ -314,4 +322,4 @@ export function getQueryArg( url, arg ) {

*
* @param {string} url URL
* @param {string} arg Query arg name
* @param {string} url URL.
* @param {string} arg Query arg name.
*

@@ -332,4 +340,4 @@ * @example

*
* @param {string} url URL
* @param {...string} args Query Args
* @param {string} url URL.
* @param {...string} args Query Args.
*

@@ -341,3 +349,3 @@ * @example

*
* @return {string} Updated URL
* @return {string} Updated URL.
*/

@@ -357,3 +365,3 @@ export function removeQueryArgs( url, ...args ) {

*
* @param {string} url The URL to test
* @param {string} url The URL to test.
*

@@ -365,5 +373,6 @@ * @example

*
* @return {string} The updated URL
* @return {string} The updated URL.
*/
export function prependHTTP( url ) {
url = url.trim();
if ( ! USABLE_HREF_REGEXP.test( url ) && ! EMAIL_REGEXP.test( url ) ) {

@@ -370,0 +379,0 @@ return 'http://' + url;

@@ -499,2 +499,14 @@ /**

} );
it( 'should remove leading whitespace before prepending HTTP', () => {
const url = ' wordpress.org';
expect( prependHTTP( url ) ).toBe( 'http://wordpress.org' );
} );
it( 'should not have trailing whitespaces', () => {
const url = 'wordpress.org ';
expect( prependHTTP( url ) ).toBe( 'http://wordpress.org' );
} );
} );

@@ -501,0 +513,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc