@wordpress/url 3.35.0 → 3.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 3.37.0 (2023-06-23)
6
+
7
+ ## 3.36.0 (2023-06-07)
8
+
5
9
  ## 3.35.0 (2023-05-24)
6
10
 
7
11
  ## 3.34.0 (2023-05-10)
@@ -29,10 +29,7 @@ var _buildQueryString = require("./build-query-string");
29
29
  *
30
30
  * @return {string} URL with arguments applied.
31
31
  */
32
- function addQueryArgs() {
33
- let url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
34
- let args = arguments.length > 1 ? arguments[1] : undefined;
35
-
32
+ function addQueryArgs(url = '', args) {
36
33
  // If no arguments are to be appended, return original URL.
37
34
  if (!args || !Object.keys(args).length) {
38
35
  return url;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/url/src/add-query-args.js"],"names":["addQueryArgs","url","args","Object","keys","length","baseUrl","queryStringIndex","indexOf","assign","substr"],"mappings":";;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,YAAT,GAAwC;AAAA,MAAjBC,GAAiB,uEAAX,EAAW;AAAA,MAAPC,IAAO;;AAC9C;AACA,MAAK,CAAEA,IAAF,IAAU,CAAEC,MAAM,CAACC,IAAP,CAAaF,IAAb,EAAoBG,MAArC,EAA8C;AAC7C,WAAOJ,GAAP;AACA;;AAED,MAAIK,OAAO,GAAGL,GAAd,CAN8C,CAQ9C;;AACA,QAAMM,gBAAgB,GAAGN,GAAG,CAACO,OAAJ,CAAa,GAAb,CAAzB;;AACA,MAAKD,gBAAgB,KAAK,CAAC,CAA3B,EAA+B;AAC9B;AACAL,IAAAA,IAAI,GAAGC,MAAM,CAACM,MAAP,CAAe,gCAAcR,GAAd,CAAf,EAAoCC,IAApC,CAAP,CAF8B,CAI9B;;AACAI,IAAAA,OAAO,GAAGA,OAAO,CAACI,MAAR,CAAgB,CAAhB,EAAmBH,gBAAnB,CAAV;AACA;;AAED,SAAOD,OAAO,GAAG,GAAV,GAAgB,wCAAkBJ,IAAlB,CAAvB;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { getQueryArgs } from './get-query-args';\nimport { buildQueryString } from './build-query-string';\n\n/**\n * Appends arguments as querystring to the provided URL. If the URL already\n * includes query arguments, the arguments are merged with (and take precedent\n * over) the existing set.\n *\n * @param {string} [url=''] URL to which arguments should be appended. If omitted,\n * only the resulting querystring is returned.\n * @param {Object} [args] Query arguments to apply to URL.\n *\n * @example\n * ```js\n * const newURL = addQueryArgs( 'https://google.com', { q: 'test' } ); // https://google.com/?q=test\n * ```\n *\n * @return {string} URL with arguments applied.\n */\nexport function addQueryArgs( url = '', args ) {\n\t// If no arguments are to be appended, return original URL.\n\tif ( ! args || ! Object.keys( args ).length ) {\n\t\treturn url;\n\t}\n\n\tlet baseUrl = url;\n\n\t// Determine whether URL already had query arguments.\n\tconst queryStringIndex = url.indexOf( '?' );\n\tif ( queryStringIndex !== -1 ) {\n\t\t// Merge into existing query arguments.\n\t\targs = Object.assign( getQueryArgs( url ), args );\n\n\t\t// Change working base URL to omit previous query arguments.\n\t\tbaseUrl = baseUrl.substr( 0, queryStringIndex );\n\t}\n\n\treturn baseUrl + '?' + buildQueryString( args );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/url/src/add-query-args.js"],"names":["addQueryArgs","url","args","Object","keys","length","baseUrl","queryStringIndex","indexOf","assign","substr"],"mappings":";;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,YAAT,CAAuBC,GAAG,GAAG,EAA7B,EAAiCC,IAAjC,EAAwC;AAC9C;AACA,MAAK,CAAEA,IAAF,IAAU,CAAEC,MAAM,CAACC,IAAP,CAAaF,IAAb,EAAoBG,MAArC,EAA8C;AAC7C,WAAOJ,GAAP;AACA;;AAED,MAAIK,OAAO,GAAGL,GAAd,CAN8C,CAQ9C;;AACA,QAAMM,gBAAgB,GAAGN,GAAG,CAACO,OAAJ,CAAa,GAAb,CAAzB;;AACA,MAAKD,gBAAgB,KAAK,CAAC,CAA3B,EAA+B;AAC9B;AACAL,IAAAA,IAAI,GAAGC,MAAM,CAACM,MAAP,CAAe,gCAAcR,GAAd,CAAf,EAAoCC,IAApC,CAAP,CAF8B,CAI9B;;AACAI,IAAAA,OAAO,GAAGA,OAAO,CAACI,MAAR,CAAgB,CAAhB,EAAmBH,gBAAnB,CAAV;AACA;;AAED,SAAOD,OAAO,GAAG,GAAV,GAAgB,wCAAkBJ,IAAlB,CAAvB;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { getQueryArgs } from './get-query-args';\nimport { buildQueryString } from './build-query-string';\n\n/**\n * Appends arguments as querystring to the provided URL. If the URL already\n * includes query arguments, the arguments are merged with (and take precedent\n * over) the existing set.\n *\n * @param {string} [url=''] URL to which arguments should be appended. If omitted,\n * only the resulting querystring is returned.\n * @param {Object} [args] Query arguments to apply to URL.\n *\n * @example\n * ```js\n * const newURL = addQueryArgs( 'https://google.com', { q: 'test' } ); // https://google.com/?q=test\n * ```\n *\n * @return {string} URL with arguments applied.\n */\nexport function addQueryArgs( url = '', args ) {\n\t// If no arguments are to be appended, return original URL.\n\tif ( ! args || ! Object.keys( args ).length ) {\n\t\treturn url;\n\t}\n\n\tlet baseUrl = url;\n\n\t// Determine whether URL already had query arguments.\n\tconst queryStringIndex = url.indexOf( '?' );\n\tif ( queryStringIndex !== -1 ) {\n\t\t// Merge into existing query arguments.\n\t\targs = Object.assign( getQueryArgs( url ), args );\n\n\t\t// Change working base URL to omit previous query arguments.\n\t\tbaseUrl = baseUrl.substr( 0, queryStringIndex );\n\t}\n\n\treturn baseUrl + '?' + buildQueryString( args );\n}\n"]}
@@ -19,8 +19,7 @@ exports.filterURLForDisplay = filterURLForDisplay;
19
19
  *
20
20
  * @return {string} Displayed URL.
21
21
  */
22
- function filterURLForDisplay(url) {
23
- let maxLength = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
22
+ function filterURLForDisplay(url, maxLength = null) {
24
23
  // Remove protocol and www prefixes.
25
24
  let filteredURL = url.replace(/^(?:https?:)\/\/(?:www\.)?/, ''); // Ends with / and only has that single slash, strip it.
26
25
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/url/src/filter-url-for-display.js"],"names":["filterURLForDisplay","url","maxLength","filteredURL","replace","match","mediaRegexp","length","split","urlPieces","file","slice","index","lastIndexOf","fileName","extension","truncatedFile"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,mBAAT,CAA8BC,GAA9B,EAAsD;AAAA,MAAnBC,SAAmB,uEAAP,IAAO;AAC5D;AACA,MAAIC,WAAW,GAAGF,GAAG,CAACG,OAAJ,CAAa,4BAAb,EAA2C,EAA3C,CAAlB,CAF4D,CAI5D;;AACA,MAAKD,WAAW,CAACE,KAAZ,CAAmB,YAAnB,CAAL,EAAyC;AACxCF,IAAAA,WAAW,GAAGA,WAAW,CAACC,OAAZ,CAAqB,GAArB,EAA0B,EAA1B,CAAd;AACA;;AAED,QAAME,WAAW,GAAG,qCAApB;;AAEA,MACC,CAAEJ,SAAF,IACAC,WAAW,CAACI,MAAZ,IAAsBL,SADtB,IAEA,CAAEC,WAAW,CAACE,KAAZ,CAAmBC,WAAnB,CAHH,EAIE;AACD,WAAOH,WAAP;AACA,GAjB2D,CAmB5D;;;AACAA,EAAAA,WAAW,GAAGA,WAAW,CAACK,KAAZ,CAAmB,GAAnB,EAA0B,CAA1B,CAAd;AACA,QAAMC,SAAS,GAAGN,WAAW,CAACK,KAAZ,CAAmB,GAAnB,CAAlB;AACA,QAAME,IAAI,GAAGD,SAAS,CAAEA,SAAS,CAACF,MAAV,GAAmB,CAArB,CAAtB;;AACA,MAAKG,IAAI,CAACH,MAAL,IAAeL,SAApB,EAAgC;AAC/B,WAAO,MAAMC,WAAW,CAACQ,KAAZ,CAAmB,CAACT,SAApB,CAAb;AACA,GAzB2D,CA2B5D;;;AACA,QAAMU,KAAK,GAAGF,IAAI,CAACG,WAAL,CAAkB,GAAlB,CAAd;AACA,QAAM,CAAEC,QAAF,EAAYC,SAAZ,IAA0B,CAC/BL,IAAI,CAACC,KAAL,CAAY,CAAZ,EAAeC,KAAf,CAD+B,EAE/BF,IAAI,CAACC,KAAL,CAAYC,KAAK,GAAG,CAApB,CAF+B,CAAhC;AAIA,QAAMI,aAAa,GAAGF,QAAQ,CAACH,KAAT,CAAgB,CAAC,CAAjB,IAAuB,GAAvB,GAA6BI,SAAnD;AACA,SACCL,IAAI,CAACC,KAAL,CAAY,CAAZ,EAAeT,SAAS,GAAGc,aAAa,CAACT,MAA1B,GAAmC,CAAlD,IACA,GADA,GAEAS,aAHD;AAKA","sourcesContent":["/**\n * Returns a URL for display.\n *\n * @param {string} url Original URL.\n * @param {number|null} maxLength URL length.\n *\n * @example\n * ```js\n * const displayUrl = filterURLForDisplay( 'https://www.wordpress.org/gutenberg/' ); // wordpress.org/gutenberg\n * const imageUrl = filterURLForDisplay( 'https://www.wordpress.org/wp-content/uploads/img.png', 20 ); // …ent/uploads/img.png\n * ```\n *\n * @return {string} Displayed URL.\n */\nexport function filterURLForDisplay( url, maxLength = null ) {\n\t// Remove protocol and www prefixes.\n\tlet filteredURL = url.replace( /^(?:https?:)\\/\\/(?:www\\.)?/, '' );\n\n\t// Ends with / and only has that single slash, strip it.\n\tif ( filteredURL.match( /^[^\\/]+\\/$/ ) ) {\n\t\tfilteredURL = filteredURL.replace( '/', '' );\n\t}\n\n\tconst mediaRegexp = /([\\w|:])*\\.(?:jpg|jpeg|gif|png|svg)/;\n\n\tif (\n\t\t! maxLength ||\n\t\tfilteredURL.length <= maxLength ||\n\t\t! filteredURL.match( mediaRegexp )\n\t) {\n\t\treturn filteredURL;\n\t}\n\n\t// If the file is not greater than max length, return last portion of URL.\n\tfilteredURL = filteredURL.split( '?' )[ 0 ];\n\tconst urlPieces = filteredURL.split( '/' );\n\tconst file = urlPieces[ urlPieces.length - 1 ];\n\tif ( file.length <= maxLength ) {\n\t\treturn '…' + filteredURL.slice( -maxLength );\n\t}\n\n\t// If the file is greater than max length, truncate the file.\n\tconst index = file.lastIndexOf( '.' );\n\tconst [ fileName, extension ] = [\n\t\tfile.slice( 0, index ),\n\t\tfile.slice( index + 1 ),\n\t];\n\tconst truncatedFile = fileName.slice( -3 ) + '.' + extension;\n\treturn (\n\t\tfile.slice( 0, maxLength - truncatedFile.length - 1 ) +\n\t\t'…' +\n\t\ttruncatedFile\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/url/src/filter-url-for-display.js"],"names":["filterURLForDisplay","url","maxLength","filteredURL","replace","match","mediaRegexp","length","split","urlPieces","file","slice","index","lastIndexOf","fileName","extension","truncatedFile"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,mBAAT,CAA8BC,GAA9B,EAAmCC,SAAS,GAAG,IAA/C,EAAsD;AAC5D;AACA,MAAIC,WAAW,GAAGF,GAAG,CAACG,OAAJ,CAAa,4BAAb,EAA2C,EAA3C,CAAlB,CAF4D,CAI5D;;AACA,MAAKD,WAAW,CAACE,KAAZ,CAAmB,YAAnB,CAAL,EAAyC;AACxCF,IAAAA,WAAW,GAAGA,WAAW,CAACC,OAAZ,CAAqB,GAArB,EAA0B,EAA1B,CAAd;AACA;;AAED,QAAME,WAAW,GAAG,qCAApB;;AAEA,MACC,CAAEJ,SAAF,IACAC,WAAW,CAACI,MAAZ,IAAsBL,SADtB,IAEA,CAAEC,WAAW,CAACE,KAAZ,CAAmBC,WAAnB,CAHH,EAIE;AACD,WAAOH,WAAP;AACA,GAjB2D,CAmB5D;;;AACAA,EAAAA,WAAW,GAAGA,WAAW,CAACK,KAAZ,CAAmB,GAAnB,EAA0B,CAA1B,CAAd;AACA,QAAMC,SAAS,GAAGN,WAAW,CAACK,KAAZ,CAAmB,GAAnB,CAAlB;AACA,QAAME,IAAI,GAAGD,SAAS,CAAEA,SAAS,CAACF,MAAV,GAAmB,CAArB,CAAtB;;AACA,MAAKG,IAAI,CAACH,MAAL,IAAeL,SAApB,EAAgC;AAC/B,WAAO,MAAMC,WAAW,CAACQ,KAAZ,CAAmB,CAACT,SAApB,CAAb;AACA,GAzB2D,CA2B5D;;;AACA,QAAMU,KAAK,GAAGF,IAAI,CAACG,WAAL,CAAkB,GAAlB,CAAd;AACA,QAAM,CAAEC,QAAF,EAAYC,SAAZ,IAA0B,CAC/BL,IAAI,CAACC,KAAL,CAAY,CAAZ,EAAeC,KAAf,CAD+B,EAE/BF,IAAI,CAACC,KAAL,CAAYC,KAAK,GAAG,CAApB,CAF+B,CAAhC;AAIA,QAAMI,aAAa,GAAGF,QAAQ,CAACH,KAAT,CAAgB,CAAC,CAAjB,IAAuB,GAAvB,GAA6BI,SAAnD;AACA,SACCL,IAAI,CAACC,KAAL,CAAY,CAAZ,EAAeT,SAAS,GAAGc,aAAa,CAACT,MAA1B,GAAmC,CAAlD,IACA,GADA,GAEAS,aAHD;AAKA","sourcesContent":["/**\n * Returns a URL for display.\n *\n * @param {string} url Original URL.\n * @param {number|null} maxLength URL length.\n *\n * @example\n * ```js\n * const displayUrl = filterURLForDisplay( 'https://www.wordpress.org/gutenberg/' ); // wordpress.org/gutenberg\n * const imageUrl = filterURLForDisplay( 'https://www.wordpress.org/wp-content/uploads/img.png', 20 ); // …ent/uploads/img.png\n * ```\n *\n * @return {string} Displayed URL.\n */\nexport function filterURLForDisplay( url, maxLength = null ) {\n\t// Remove protocol and www prefixes.\n\tlet filteredURL = url.replace( /^(?:https?:)\\/\\/(?:www\\.)?/, '' );\n\n\t// Ends with / and only has that single slash, strip it.\n\tif ( filteredURL.match( /^[^\\/]+\\/$/ ) ) {\n\t\tfilteredURL = filteredURL.replace( '/', '' );\n\t}\n\n\tconst mediaRegexp = /([\\w|:])*\\.(?:jpg|jpeg|gif|png|svg)/;\n\n\tif (\n\t\t! maxLength ||\n\t\tfilteredURL.length <= maxLength ||\n\t\t! filteredURL.match( mediaRegexp )\n\t) {\n\t\treturn filteredURL;\n\t}\n\n\t// If the file is not greater than max length, return last portion of URL.\n\tfilteredURL = filteredURL.split( '?' )[ 0 ];\n\tconst urlPieces = filteredURL.split( '/' );\n\tconst file = urlPieces[ urlPieces.length - 1 ];\n\tif ( file.length <= maxLength ) {\n\t\treturn '…' + filteredURL.slice( -maxLength );\n\t}\n\n\t// If the file is greater than max length, truncate the file.\n\tconst index = file.lastIndexOf( '.' );\n\tconst [ fileName, extension ] = [\n\t\tfile.slice( 0, index ),\n\t\tfile.slice( index + 1 ),\n\t];\n\tconst truncatedFile = fileName.slice( -3 ) + '.' + extension;\n\treturn (\n\t\tfile.slice( 0, maxLength - truncatedFile.length - 1 ) +\n\t\t'…' +\n\t\ttruncatedFile\n\t);\n}\n"]}
@@ -26,7 +26,7 @@ var _buildQueryString = require("./build-query-string");
26
26
  *
27
27
  * @return {string} Updated URL.
28
28
  */
29
- function removeQueryArgs(url) {
29
+ function removeQueryArgs(url, ...args) {
30
30
  const queryStringIndex = url.indexOf('?');
31
31
 
32
32
  if (queryStringIndex === -1) {
@@ -35,11 +35,6 @@ function removeQueryArgs(url) {
35
35
 
36
36
  const query = (0, _getQueryArgs.getQueryArgs)(url);
37
37
  const baseURL = url.substr(0, queryStringIndex);
38
-
39
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
40
- args[_key - 1] = arguments[_key];
41
- }
42
-
43
38
  args.forEach(arg => delete query[arg]);
44
39
  const queryString = (0, _buildQueryString.buildQueryString)(query);
45
40
  return queryString ? baseURL + '?' + queryString : baseURL;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/url/src/remove-query-args.js"],"names":["removeQueryArgs","url","queryStringIndex","indexOf","query","baseURL","substr","args","forEach","arg","queryString"],"mappings":";;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,eAAT,CAA0BC,GAA1B,EAAyC;AAC/C,QAAMC,gBAAgB,GAAGD,GAAG,CAACE,OAAJ,CAAa,GAAb,CAAzB;;AACA,MAAKD,gBAAgB,KAAK,CAAC,CAA3B,EAA+B;AAC9B,WAAOD,GAAP;AACA;;AAED,QAAMG,KAAK,GAAG,gCAAcH,GAAd,CAAd;AACA,QAAMI,OAAO,GAAGJ,GAAG,CAACK,MAAJ,CAAY,CAAZ,EAAeJ,gBAAf,CAAhB;;AAP+C,oCAAPK,IAAO;AAAPA,IAAAA,IAAO;AAAA;;AAQ/CA,EAAAA,IAAI,CAACC,OAAL,CAAgBC,GAAF,IAAW,OAAOL,KAAK,CAAEK,GAAF,CAArC;AACA,QAAMC,WAAW,GAAG,wCAAkBN,KAAlB,CAApB;AACA,SAAOM,WAAW,GAAGL,OAAO,GAAG,GAAV,GAAgBK,WAAnB,GAAiCL,OAAnD;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { getQueryArgs } from './get-query-args';\nimport { buildQueryString } from './build-query-string';\n\n/**\n * Removes arguments from the query string of the url\n *\n * @param {string} url URL.\n * @param {...string} args Query Args.\n *\n * @example\n * ```js\n * const newUrl = removeQueryArgs( 'https://wordpress.org?foo=bar&bar=baz&baz=foobar', 'foo', 'bar' ); // https://wordpress.org?baz=foobar\n * ```\n *\n * @return {string} Updated URL.\n */\nexport function removeQueryArgs( url, ...args ) {\n\tconst queryStringIndex = url.indexOf( '?' );\n\tif ( queryStringIndex === -1 ) {\n\t\treturn url;\n\t}\n\n\tconst query = getQueryArgs( url );\n\tconst baseURL = url.substr( 0, queryStringIndex );\n\targs.forEach( ( arg ) => delete query[ arg ] );\n\tconst queryString = buildQueryString( query );\n\treturn queryString ? baseURL + '?' + queryString : baseURL;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/url/src/remove-query-args.js"],"names":["removeQueryArgs","url","args","queryStringIndex","indexOf","query","baseURL","substr","forEach","arg","queryString"],"mappings":";;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,eAAT,CAA0BC,GAA1B,EAA+B,GAAGC,IAAlC,EAAyC;AAC/C,QAAMC,gBAAgB,GAAGF,GAAG,CAACG,OAAJ,CAAa,GAAb,CAAzB;;AACA,MAAKD,gBAAgB,KAAK,CAAC,CAA3B,EAA+B;AAC9B,WAAOF,GAAP;AACA;;AAED,QAAMI,KAAK,GAAG,gCAAcJ,GAAd,CAAd;AACA,QAAMK,OAAO,GAAGL,GAAG,CAACM,MAAJ,CAAY,CAAZ,EAAeJ,gBAAf,CAAhB;AACAD,EAAAA,IAAI,CAACM,OAAL,CAAgBC,GAAF,IAAW,OAAOJ,KAAK,CAAEI,GAAF,CAArC;AACA,QAAMC,WAAW,GAAG,wCAAkBL,KAAlB,CAApB;AACA,SAAOK,WAAW,GAAGJ,OAAO,GAAG,GAAV,GAAgBI,WAAnB,GAAiCJ,OAAnD;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { getQueryArgs } from './get-query-args';\nimport { buildQueryString } from './build-query-string';\n\n/**\n * Removes arguments from the query string of the url\n *\n * @param {string} url URL.\n * @param {...string} args Query Args.\n *\n * @example\n * ```js\n * const newUrl = removeQueryArgs( 'https://wordpress.org?foo=bar&bar=baz&baz=foobar', 'foo', 'bar' ); // https://wordpress.org?baz=foobar\n * ```\n *\n * @return {string} Updated URL.\n */\nexport function removeQueryArgs( url, ...args ) {\n\tconst queryStringIndex = url.indexOf( '?' );\n\tif ( queryStringIndex === -1 ) {\n\t\treturn url;\n\t}\n\n\tconst query = getQueryArgs( url );\n\tconst baseURL = url.substr( 0, queryStringIndex );\n\targs.forEach( ( arg ) => delete query[ arg ] );\n\tconst queryString = buildQueryString( query );\n\treturn queryString ? baseURL + '?' + queryString : baseURL;\n}\n"]}
@@ -20,10 +20,7 @@ import { buildQueryString } from './build-query-string';
20
20
  * @return {string} URL with arguments applied.
21
21
  */
22
22
 
23
- export function addQueryArgs() {
24
- let url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
25
- let args = arguments.length > 1 ? arguments[1] : undefined;
26
-
23
+ export function addQueryArgs(url = '', args) {
27
24
  // If no arguments are to be appended, return original URL.
28
25
  if (!args || !Object.keys(args).length) {
29
26
  return url;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/url/src/add-query-args.js"],"names":["getQueryArgs","buildQueryString","addQueryArgs","url","args","Object","keys","length","baseUrl","queryStringIndex","indexOf","assign","substr"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAT,QAA6B,kBAA7B;AACA,SAASC,gBAAT,QAAiC,sBAAjC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,YAAT,GAAwC;AAAA,MAAjBC,GAAiB,uEAAX,EAAW;AAAA,MAAPC,IAAO;;AAC9C;AACA,MAAK,CAAEA,IAAF,IAAU,CAAEC,MAAM,CAACC,IAAP,CAAaF,IAAb,EAAoBG,MAArC,EAA8C;AAC7C,WAAOJ,GAAP;AACA;;AAED,MAAIK,OAAO,GAAGL,GAAd,CAN8C,CAQ9C;;AACA,QAAMM,gBAAgB,GAAGN,GAAG,CAACO,OAAJ,CAAa,GAAb,CAAzB;;AACA,MAAKD,gBAAgB,KAAK,CAAC,CAA3B,EAA+B;AAC9B;AACAL,IAAAA,IAAI,GAAGC,MAAM,CAACM,MAAP,CAAeX,YAAY,CAAEG,GAAF,CAA3B,EAAoCC,IAApC,CAAP,CAF8B,CAI9B;;AACAI,IAAAA,OAAO,GAAGA,OAAO,CAACI,MAAR,CAAgB,CAAhB,EAAmBH,gBAAnB,CAAV;AACA;;AAED,SAAOD,OAAO,GAAG,GAAV,GAAgBP,gBAAgB,CAAEG,IAAF,CAAvC;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { getQueryArgs } from './get-query-args';\nimport { buildQueryString } from './build-query-string';\n\n/**\n * Appends arguments as querystring to the provided URL. If the URL already\n * includes query arguments, the arguments are merged with (and take precedent\n * over) the existing set.\n *\n * @param {string} [url=''] URL to which arguments should be appended. If omitted,\n * only the resulting querystring is returned.\n * @param {Object} [args] Query arguments to apply to URL.\n *\n * @example\n * ```js\n * const newURL = addQueryArgs( 'https://google.com', { q: 'test' } ); // https://google.com/?q=test\n * ```\n *\n * @return {string} URL with arguments applied.\n */\nexport function addQueryArgs( url = '', args ) {\n\t// If no arguments are to be appended, return original URL.\n\tif ( ! args || ! Object.keys( args ).length ) {\n\t\treturn url;\n\t}\n\n\tlet baseUrl = url;\n\n\t// Determine whether URL already had query arguments.\n\tconst queryStringIndex = url.indexOf( '?' );\n\tif ( queryStringIndex !== -1 ) {\n\t\t// Merge into existing query arguments.\n\t\targs = Object.assign( getQueryArgs( url ), args );\n\n\t\t// Change working base URL to omit previous query arguments.\n\t\tbaseUrl = baseUrl.substr( 0, queryStringIndex );\n\t}\n\n\treturn baseUrl + '?' + buildQueryString( args );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/url/src/add-query-args.js"],"names":["getQueryArgs","buildQueryString","addQueryArgs","url","args","Object","keys","length","baseUrl","queryStringIndex","indexOf","assign","substr"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAT,QAA6B,kBAA7B;AACA,SAASC,gBAAT,QAAiC,sBAAjC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,YAAT,CAAuBC,GAAG,GAAG,EAA7B,EAAiCC,IAAjC,EAAwC;AAC9C;AACA,MAAK,CAAEA,IAAF,IAAU,CAAEC,MAAM,CAACC,IAAP,CAAaF,IAAb,EAAoBG,MAArC,EAA8C;AAC7C,WAAOJ,GAAP;AACA;;AAED,MAAIK,OAAO,GAAGL,GAAd,CAN8C,CAQ9C;;AACA,QAAMM,gBAAgB,GAAGN,GAAG,CAACO,OAAJ,CAAa,GAAb,CAAzB;;AACA,MAAKD,gBAAgB,KAAK,CAAC,CAA3B,EAA+B;AAC9B;AACAL,IAAAA,IAAI,GAAGC,MAAM,CAACM,MAAP,CAAeX,YAAY,CAAEG,GAAF,CAA3B,EAAoCC,IAApC,CAAP,CAF8B,CAI9B;;AACAI,IAAAA,OAAO,GAAGA,OAAO,CAACI,MAAR,CAAgB,CAAhB,EAAmBH,gBAAnB,CAAV;AACA;;AAED,SAAOD,OAAO,GAAG,GAAV,GAAgBP,gBAAgB,CAAEG,IAAF,CAAvC;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { getQueryArgs } from './get-query-args';\nimport { buildQueryString } from './build-query-string';\n\n/**\n * Appends arguments as querystring to the provided URL. If the URL already\n * includes query arguments, the arguments are merged with (and take precedent\n * over) the existing set.\n *\n * @param {string} [url=''] URL to which arguments should be appended. If omitted,\n * only the resulting querystring is returned.\n * @param {Object} [args] Query arguments to apply to URL.\n *\n * @example\n * ```js\n * const newURL = addQueryArgs( 'https://google.com', { q: 'test' } ); // https://google.com/?q=test\n * ```\n *\n * @return {string} URL with arguments applied.\n */\nexport function addQueryArgs( url = '', args ) {\n\t// If no arguments are to be appended, return original URL.\n\tif ( ! args || ! Object.keys( args ).length ) {\n\t\treturn url;\n\t}\n\n\tlet baseUrl = url;\n\n\t// Determine whether URL already had query arguments.\n\tconst queryStringIndex = url.indexOf( '?' );\n\tif ( queryStringIndex !== -1 ) {\n\t\t// Merge into existing query arguments.\n\t\targs = Object.assign( getQueryArgs( url ), args );\n\n\t\t// Change working base URL to omit previous query arguments.\n\t\tbaseUrl = baseUrl.substr( 0, queryStringIndex );\n\t}\n\n\treturn baseUrl + '?' + buildQueryString( args );\n}\n"]}
@@ -12,8 +12,7 @@
12
12
  *
13
13
  * @return {string} Displayed URL.
14
14
  */
15
- export function filterURLForDisplay(url) {
16
- let maxLength = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
15
+ export function filterURLForDisplay(url, maxLength = null) {
17
16
  // Remove protocol and www prefixes.
18
17
  let filteredURL = url.replace(/^(?:https?:)\/\/(?:www\.)?/, ''); // Ends with / and only has that single slash, strip it.
19
18
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/url/src/filter-url-for-display.js"],"names":["filterURLForDisplay","url","maxLength","filteredURL","replace","match","mediaRegexp","length","split","urlPieces","file","slice","index","lastIndexOf","fileName","extension","truncatedFile"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,mBAAT,CAA8BC,GAA9B,EAAsD;AAAA,MAAnBC,SAAmB,uEAAP,IAAO;AAC5D;AACA,MAAIC,WAAW,GAAGF,GAAG,CAACG,OAAJ,CAAa,4BAAb,EAA2C,EAA3C,CAAlB,CAF4D,CAI5D;;AACA,MAAKD,WAAW,CAACE,KAAZ,CAAmB,YAAnB,CAAL,EAAyC;AACxCF,IAAAA,WAAW,GAAGA,WAAW,CAACC,OAAZ,CAAqB,GAArB,EAA0B,EAA1B,CAAd;AACA;;AAED,QAAME,WAAW,GAAG,qCAApB;;AAEA,MACC,CAAEJ,SAAF,IACAC,WAAW,CAACI,MAAZ,IAAsBL,SADtB,IAEA,CAAEC,WAAW,CAACE,KAAZ,CAAmBC,WAAnB,CAHH,EAIE;AACD,WAAOH,WAAP;AACA,GAjB2D,CAmB5D;;;AACAA,EAAAA,WAAW,GAAGA,WAAW,CAACK,KAAZ,CAAmB,GAAnB,EAA0B,CAA1B,CAAd;AACA,QAAMC,SAAS,GAAGN,WAAW,CAACK,KAAZ,CAAmB,GAAnB,CAAlB;AACA,QAAME,IAAI,GAAGD,SAAS,CAAEA,SAAS,CAACF,MAAV,GAAmB,CAArB,CAAtB;;AACA,MAAKG,IAAI,CAACH,MAAL,IAAeL,SAApB,EAAgC;AAC/B,WAAO,MAAMC,WAAW,CAACQ,KAAZ,CAAmB,CAACT,SAApB,CAAb;AACA,GAzB2D,CA2B5D;;;AACA,QAAMU,KAAK,GAAGF,IAAI,CAACG,WAAL,CAAkB,GAAlB,CAAd;AACA,QAAM,CAAEC,QAAF,EAAYC,SAAZ,IAA0B,CAC/BL,IAAI,CAACC,KAAL,CAAY,CAAZ,EAAeC,KAAf,CAD+B,EAE/BF,IAAI,CAACC,KAAL,CAAYC,KAAK,GAAG,CAApB,CAF+B,CAAhC;AAIA,QAAMI,aAAa,GAAGF,QAAQ,CAACH,KAAT,CAAgB,CAAC,CAAjB,IAAuB,GAAvB,GAA6BI,SAAnD;AACA,SACCL,IAAI,CAACC,KAAL,CAAY,CAAZ,EAAeT,SAAS,GAAGc,aAAa,CAACT,MAA1B,GAAmC,CAAlD,IACA,GADA,GAEAS,aAHD;AAKA","sourcesContent":["/**\n * Returns a URL for display.\n *\n * @param {string} url Original URL.\n * @param {number|null} maxLength URL length.\n *\n * @example\n * ```js\n * const displayUrl = filterURLForDisplay( 'https://www.wordpress.org/gutenberg/' ); // wordpress.org/gutenberg\n * const imageUrl = filterURLForDisplay( 'https://www.wordpress.org/wp-content/uploads/img.png', 20 ); // …ent/uploads/img.png\n * ```\n *\n * @return {string} Displayed URL.\n */\nexport function filterURLForDisplay( url, maxLength = null ) {\n\t// Remove protocol and www prefixes.\n\tlet filteredURL = url.replace( /^(?:https?:)\\/\\/(?:www\\.)?/, '' );\n\n\t// Ends with / and only has that single slash, strip it.\n\tif ( filteredURL.match( /^[^\\/]+\\/$/ ) ) {\n\t\tfilteredURL = filteredURL.replace( '/', '' );\n\t}\n\n\tconst mediaRegexp = /([\\w|:])*\\.(?:jpg|jpeg|gif|png|svg)/;\n\n\tif (\n\t\t! maxLength ||\n\t\tfilteredURL.length <= maxLength ||\n\t\t! filteredURL.match( mediaRegexp )\n\t) {\n\t\treturn filteredURL;\n\t}\n\n\t// If the file is not greater than max length, return last portion of URL.\n\tfilteredURL = filteredURL.split( '?' )[ 0 ];\n\tconst urlPieces = filteredURL.split( '/' );\n\tconst file = urlPieces[ urlPieces.length - 1 ];\n\tif ( file.length <= maxLength ) {\n\t\treturn '…' + filteredURL.slice( -maxLength );\n\t}\n\n\t// If the file is greater than max length, truncate the file.\n\tconst index = file.lastIndexOf( '.' );\n\tconst [ fileName, extension ] = [\n\t\tfile.slice( 0, index ),\n\t\tfile.slice( index + 1 ),\n\t];\n\tconst truncatedFile = fileName.slice( -3 ) + '.' + extension;\n\treturn (\n\t\tfile.slice( 0, maxLength - truncatedFile.length - 1 ) +\n\t\t'…' +\n\t\ttruncatedFile\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/url/src/filter-url-for-display.js"],"names":["filterURLForDisplay","url","maxLength","filteredURL","replace","match","mediaRegexp","length","split","urlPieces","file","slice","index","lastIndexOf","fileName","extension","truncatedFile"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,mBAAT,CAA8BC,GAA9B,EAAmCC,SAAS,GAAG,IAA/C,EAAsD;AAC5D;AACA,MAAIC,WAAW,GAAGF,GAAG,CAACG,OAAJ,CAAa,4BAAb,EAA2C,EAA3C,CAAlB,CAF4D,CAI5D;;AACA,MAAKD,WAAW,CAACE,KAAZ,CAAmB,YAAnB,CAAL,EAAyC;AACxCF,IAAAA,WAAW,GAAGA,WAAW,CAACC,OAAZ,CAAqB,GAArB,EAA0B,EAA1B,CAAd;AACA;;AAED,QAAME,WAAW,GAAG,qCAApB;;AAEA,MACC,CAAEJ,SAAF,IACAC,WAAW,CAACI,MAAZ,IAAsBL,SADtB,IAEA,CAAEC,WAAW,CAACE,KAAZ,CAAmBC,WAAnB,CAHH,EAIE;AACD,WAAOH,WAAP;AACA,GAjB2D,CAmB5D;;;AACAA,EAAAA,WAAW,GAAGA,WAAW,CAACK,KAAZ,CAAmB,GAAnB,EAA0B,CAA1B,CAAd;AACA,QAAMC,SAAS,GAAGN,WAAW,CAACK,KAAZ,CAAmB,GAAnB,CAAlB;AACA,QAAME,IAAI,GAAGD,SAAS,CAAEA,SAAS,CAACF,MAAV,GAAmB,CAArB,CAAtB;;AACA,MAAKG,IAAI,CAACH,MAAL,IAAeL,SAApB,EAAgC;AAC/B,WAAO,MAAMC,WAAW,CAACQ,KAAZ,CAAmB,CAACT,SAApB,CAAb;AACA,GAzB2D,CA2B5D;;;AACA,QAAMU,KAAK,GAAGF,IAAI,CAACG,WAAL,CAAkB,GAAlB,CAAd;AACA,QAAM,CAAEC,QAAF,EAAYC,SAAZ,IAA0B,CAC/BL,IAAI,CAACC,KAAL,CAAY,CAAZ,EAAeC,KAAf,CAD+B,EAE/BF,IAAI,CAACC,KAAL,CAAYC,KAAK,GAAG,CAApB,CAF+B,CAAhC;AAIA,QAAMI,aAAa,GAAGF,QAAQ,CAACH,KAAT,CAAgB,CAAC,CAAjB,IAAuB,GAAvB,GAA6BI,SAAnD;AACA,SACCL,IAAI,CAACC,KAAL,CAAY,CAAZ,EAAeT,SAAS,GAAGc,aAAa,CAACT,MAA1B,GAAmC,CAAlD,IACA,GADA,GAEAS,aAHD;AAKA","sourcesContent":["/**\n * Returns a URL for display.\n *\n * @param {string} url Original URL.\n * @param {number|null} maxLength URL length.\n *\n * @example\n * ```js\n * const displayUrl = filterURLForDisplay( 'https://www.wordpress.org/gutenberg/' ); // wordpress.org/gutenberg\n * const imageUrl = filterURLForDisplay( 'https://www.wordpress.org/wp-content/uploads/img.png', 20 ); // …ent/uploads/img.png\n * ```\n *\n * @return {string} Displayed URL.\n */\nexport function filterURLForDisplay( url, maxLength = null ) {\n\t// Remove protocol and www prefixes.\n\tlet filteredURL = url.replace( /^(?:https?:)\\/\\/(?:www\\.)?/, '' );\n\n\t// Ends with / and only has that single slash, strip it.\n\tif ( filteredURL.match( /^[^\\/]+\\/$/ ) ) {\n\t\tfilteredURL = filteredURL.replace( '/', '' );\n\t}\n\n\tconst mediaRegexp = /([\\w|:])*\\.(?:jpg|jpeg|gif|png|svg)/;\n\n\tif (\n\t\t! maxLength ||\n\t\tfilteredURL.length <= maxLength ||\n\t\t! filteredURL.match( mediaRegexp )\n\t) {\n\t\treturn filteredURL;\n\t}\n\n\t// If the file is not greater than max length, return last portion of URL.\n\tfilteredURL = filteredURL.split( '?' )[ 0 ];\n\tconst urlPieces = filteredURL.split( '/' );\n\tconst file = urlPieces[ urlPieces.length - 1 ];\n\tif ( file.length <= maxLength ) {\n\t\treturn '…' + filteredURL.slice( -maxLength );\n\t}\n\n\t// If the file is greater than max length, truncate the file.\n\tconst index = file.lastIndexOf( '.' );\n\tconst [ fileName, extension ] = [\n\t\tfile.slice( 0, index ),\n\t\tfile.slice( index + 1 ),\n\t];\n\tconst truncatedFile = fileName.slice( -3 ) + '.' + extension;\n\treturn (\n\t\tfile.slice( 0, maxLength - truncatedFile.length - 1 ) +\n\t\t'…' +\n\t\ttruncatedFile\n\t);\n}\n"]}
@@ -17,7 +17,7 @@ import { buildQueryString } from './build-query-string';
17
17
  * @return {string} Updated URL.
18
18
  */
19
19
 
20
- export function removeQueryArgs(url) {
20
+ export function removeQueryArgs(url, ...args) {
21
21
  const queryStringIndex = url.indexOf('?');
22
22
 
23
23
  if (queryStringIndex === -1) {
@@ -26,11 +26,6 @@ export function removeQueryArgs(url) {
26
26
 
27
27
  const query = getQueryArgs(url);
28
28
  const baseURL = url.substr(0, queryStringIndex);
29
-
30
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
31
- args[_key - 1] = arguments[_key];
32
- }
33
-
34
29
  args.forEach(arg => delete query[arg]);
35
30
  const queryString = buildQueryString(query);
36
31
  return queryString ? baseURL + '?' + queryString : baseURL;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/url/src/remove-query-args.js"],"names":["getQueryArgs","buildQueryString","removeQueryArgs","url","queryStringIndex","indexOf","query","baseURL","substr","args","forEach","arg","queryString"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAT,QAA6B,kBAA7B;AACA,SAASC,gBAAT,QAAiC,sBAAjC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,eAAT,CAA0BC,GAA1B,EAAyC;AAC/C,QAAMC,gBAAgB,GAAGD,GAAG,CAACE,OAAJ,CAAa,GAAb,CAAzB;;AACA,MAAKD,gBAAgB,KAAK,CAAC,CAA3B,EAA+B;AAC9B,WAAOD,GAAP;AACA;;AAED,QAAMG,KAAK,GAAGN,YAAY,CAAEG,GAAF,CAA1B;AACA,QAAMI,OAAO,GAAGJ,GAAG,CAACK,MAAJ,CAAY,CAAZ,EAAeJ,gBAAf,CAAhB;;AAP+C,oCAAPK,IAAO;AAAPA,IAAAA,IAAO;AAAA;;AAQ/CA,EAAAA,IAAI,CAACC,OAAL,CAAgBC,GAAF,IAAW,OAAOL,KAAK,CAAEK,GAAF,CAArC;AACA,QAAMC,WAAW,GAAGX,gBAAgB,CAAEK,KAAF,CAApC;AACA,SAAOM,WAAW,GAAGL,OAAO,GAAG,GAAV,GAAgBK,WAAnB,GAAiCL,OAAnD;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { getQueryArgs } from './get-query-args';\nimport { buildQueryString } from './build-query-string';\n\n/**\n * Removes arguments from the query string of the url\n *\n * @param {string} url URL.\n * @param {...string} args Query Args.\n *\n * @example\n * ```js\n * const newUrl = removeQueryArgs( 'https://wordpress.org?foo=bar&bar=baz&baz=foobar', 'foo', 'bar' ); // https://wordpress.org?baz=foobar\n * ```\n *\n * @return {string} Updated URL.\n */\nexport function removeQueryArgs( url, ...args ) {\n\tconst queryStringIndex = url.indexOf( '?' );\n\tif ( queryStringIndex === -1 ) {\n\t\treturn url;\n\t}\n\n\tconst query = getQueryArgs( url );\n\tconst baseURL = url.substr( 0, queryStringIndex );\n\targs.forEach( ( arg ) => delete query[ arg ] );\n\tconst queryString = buildQueryString( query );\n\treturn queryString ? baseURL + '?' + queryString : baseURL;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/url/src/remove-query-args.js"],"names":["getQueryArgs","buildQueryString","removeQueryArgs","url","args","queryStringIndex","indexOf","query","baseURL","substr","forEach","arg","queryString"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAT,QAA6B,kBAA7B;AACA,SAASC,gBAAT,QAAiC,sBAAjC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,eAAT,CAA0BC,GAA1B,EAA+B,GAAGC,IAAlC,EAAyC;AAC/C,QAAMC,gBAAgB,GAAGF,GAAG,CAACG,OAAJ,CAAa,GAAb,CAAzB;;AACA,MAAKD,gBAAgB,KAAK,CAAC,CAA3B,EAA+B;AAC9B,WAAOF,GAAP;AACA;;AAED,QAAMI,KAAK,GAAGP,YAAY,CAAEG,GAAF,CAA1B;AACA,QAAMK,OAAO,GAAGL,GAAG,CAACM,MAAJ,CAAY,CAAZ,EAAeJ,gBAAf,CAAhB;AACAD,EAAAA,IAAI,CAACM,OAAL,CAAgBC,GAAF,IAAW,OAAOJ,KAAK,CAAEI,GAAF,CAArC;AACA,QAAMC,WAAW,GAAGX,gBAAgB,CAAEM,KAAF,CAApC;AACA,SAAOK,WAAW,GAAGJ,OAAO,GAAG,GAAV,GAAgBI,WAAnB,GAAiCJ,OAAnD;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { getQueryArgs } from './get-query-args';\nimport { buildQueryString } from './build-query-string';\n\n/**\n * Removes arguments from the query string of the url\n *\n * @param {string} url URL.\n * @param {...string} args Query Args.\n *\n * @example\n * ```js\n * const newUrl = removeQueryArgs( 'https://wordpress.org?foo=bar&bar=baz&baz=foobar', 'foo', 'bar' ); // https://wordpress.org?baz=foobar\n * ```\n *\n * @return {string} Updated URL.\n */\nexport function removeQueryArgs( url, ...args ) {\n\tconst queryStringIndex = url.indexOf( '?' );\n\tif ( queryStringIndex === -1 ) {\n\t\treturn url;\n\t}\n\n\tconst query = getQueryArgs( url );\n\tconst baseURL = url.substr( 0, queryStringIndex );\n\targs.forEach( ( arg ) => delete query[ arg ] );\n\tconst queryString = buildQueryString( query );\n\treturn queryString ? baseURL + '?' + queryString : baseURL;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/url",
3
- "version": "3.35.0",
3
+ "version": "3.37.0",
4
4
  "description": "WordPress URL utilities.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -33,5 +33,5 @@
33
33
  "publishConfig": {
34
34
  "access": "public"
35
35
  },
36
- "gitHead": "c7c79cb11b677adcbf06cf5f8cfb6c5ec1699f19"
36
+ "gitHead": "d47d8069e1aae05d4a16dc287902eb90edcbff50"
37
37
  }