@wordpress/url
Advanced tools
@@ -9,3 +9,3 @@ /** | ||
| * | ||
| * This replicates some of what `sanitize_title()` does in WordPress core, but | ||
| * This replicates some of what `sanitize_title_with_dashes()` does in WordPress core, but | ||
| * is only designed to approximate what the slug will be. | ||
@@ -28,4 +28,8 @@ * | ||
| return removeAccents(string) | ||
| // Convert  , &ndash, and &mdash to hyphens. | ||
| .replace(/( |–|—)/g, '-') | ||
| // Convert each group of whitespace, periods, and forward slashes to a hyphen. | ||
| .replace(/[\s\./]+/g, '-') | ||
| // Remove all HTML entities. | ||
| .replace(/&\S+?;/g, '') | ||
| // Remove anything that's not a letter, number, underscore or hyphen. | ||
@@ -32,0 +36,0 @@ .replace(/[^\p{L}\p{N}_-]+/gu, '') |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"names":["removeAccents","cleanForSlug","string","replace","toLowerCase"],"sources":["@wordpress/url/src/clean-for-slug.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport removeAccents from 'remove-accents';\n\n/**\n * Performs some basic cleanup of a string for use as a post slug.\n *\n * This replicates some of what `sanitize_title()` does in WordPress core, but\n * is only designed to approximate what the slug will be.\n *\n * Converts Latin-1 Supplement and Latin Extended-A letters to basic Latin\n * letters. Removes combining diacritical marks. Converts whitespace, periods,\n * and forward slashes to hyphens. Removes any remaining non-word characters\n * except hyphens. Converts remaining string to lowercase. It does not account\n * for octets, HTML entities, or other encoded characters.\n *\n * @param {string} string Title or slug to be processed.\n *\n * @return {string} Processed string.\n */\nexport function cleanForSlug( string ) {\n\tif ( ! string ) {\n\t\treturn '';\n\t}\n\treturn (\n\t\tremoveAccents( string )\n\t\t\t// Convert each group of whitespace, periods, and forward slashes to a hyphen.\n\t\t\t.replace( /[\\s\\./]+/g, '-' )\n\t\t\t// Remove anything that's not a letter, number, underscore or hyphen.\n\t\t\t.replace( /[^\\p{L}\\p{N}_-]+/gu, '' )\n\t\t\t// Convert to lowercase\n\t\t\t.toLowerCase()\n\t\t\t// Replace multiple hyphens with a single one.\n\t\t\t.replace( /-+/g, '-' )\n\t\t\t// Remove any remaining leading or trailing hyphens.\n\t\t\t.replace( /(^-+)|(-+$)/g, '' )\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,aAAa,MAAM,gBAAgB;;AAE1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAAEC,MAAM,EAAG;EACtC,IAAK,CAAEA,MAAM,EAAG;IACf,OAAO,EAAE;EACV;EACA,OACCF,aAAa,CAAEE,MAAO;EACrB;EAAA,CACCC,OAAO,CAAE,WAAW,EAAE,GAAI;EAC3B;EAAA,CACCA,OAAO,CAAE,oBAAoB,EAAE,EAAG;EACnC;EAAA,CACCC,WAAW,CAAC;EACb;EAAA,CACCD,OAAO,CAAE,KAAK,EAAE,GAAI;EACrB;EAAA,CACCA,OAAO,CAAE,cAAc,EAAE,EAAG,CAAC;AAEjC","ignoreList":[]} | ||
| {"version":3,"names":["removeAccents","cleanForSlug","string","replace","toLowerCase"],"sources":["@wordpress/url/src/clean-for-slug.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport removeAccents from 'remove-accents';\n\n/**\n * Performs some basic cleanup of a string for use as a post slug.\n *\n * This replicates some of what `sanitize_title_with_dashes()` does in WordPress core, but\n * is only designed to approximate what the slug will be.\n *\n * Converts Latin-1 Supplement and Latin Extended-A letters to basic Latin\n * letters. Removes combining diacritical marks. Converts whitespace, periods,\n * and forward slashes to hyphens. Removes any remaining non-word characters\n * except hyphens. Converts remaining string to lowercase. It does not account\n * for octets, HTML entities, or other encoded characters.\n *\n * @param {string} string Title or slug to be processed.\n *\n * @return {string} Processed string.\n */\nexport function cleanForSlug( string ) {\n\tif ( ! string ) {\n\t\treturn '';\n\t}\n\treturn (\n\t\tremoveAccents( string )\n\t\t\t// Convert  , &ndash, and &mdash to hyphens.\n\t\t\t.replace( /( |–|—)/g, '-' )\n\t\t\t// Convert each group of whitespace, periods, and forward slashes to a hyphen.\n\t\t\t.replace( /[\\s\\./]+/g, '-' )\n\t\t\t// Remove all HTML entities.\n\t\t\t.replace( /&\\S+?;/g, '' )\n\t\t\t// Remove anything that's not a letter, number, underscore or hyphen.\n\t\t\t.replace( /[^\\p{L}\\p{N}_-]+/gu, '' )\n\t\t\t// Convert to lowercase\n\t\t\t.toLowerCase()\n\t\t\t// Replace multiple hyphens with a single one.\n\t\t\t.replace( /-+/g, '-' )\n\t\t\t// Remove any remaining leading or trailing hyphens.\n\t\t\t.replace( /(^-+)|(-+$)/g, '' )\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,aAAa,MAAM,gBAAgB;;AAE1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAAEC,MAAM,EAAG;EACtC,IAAK,CAAEA,MAAM,EAAG;IACf,OAAO,EAAE;EACV;EACA,OACCF,aAAa,CAAEE,MAAO;EACrB;EAAA,CACCC,OAAO,CAAE,2BAA2B,EAAE,GAAI;EAC3C;EAAA,CACCA,OAAO,CAAE,WAAW,EAAE,GAAI;EAC3B;EAAA,CACCA,OAAO,CAAE,SAAS,EAAE,EAAG;EACxB;EAAA,CACCA,OAAO,CAAE,oBAAoB,EAAE,EAAG;EACnC;EAAA,CACCC,WAAW,CAAC;EACb;EAAA,CACCD,OAAO,CAAE,KAAK,EAAE,GAAI;EACrB;EAAA,CACCA,OAAO,CAAE,cAAc,EAAE,EAAG,CAAC;AAEjC","ignoreList":[]} |
| /** | ||
| * Performs some basic cleanup of a string for use as a post slug. | ||
| * | ||
| * This replicates some of what `sanitize_title()` does in WordPress core, but | ||
| * This replicates some of what `sanitize_title_with_dashes()` does in WordPress core, but | ||
| * is only designed to approximate what the slug will be. | ||
@@ -6,0 +6,0 @@ * |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"clean-for-slug.d.ts","sourceRoot":"","sources":["../src/clean-for-slug.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;GAeG;AACH,qCAJW,MAAM,GAEL,MAAM,CAmBjB"} | ||
| {"version":3,"file":"clean-for-slug.d.ts","sourceRoot":"","sources":["../src/clean-for-slug.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;GAeG;AACH,qCAJW,MAAM,GAEL,MAAM,CAuBjB"} |
@@ -16,3 +16,3 @@ "use strict"; | ||
| * | ||
| * This replicates some of what `sanitize_title()` does in WordPress core, but | ||
| * This replicates some of what `sanitize_title_with_dashes()` does in WordPress core, but | ||
| * is only designed to approximate what the slug will be. | ||
@@ -35,4 +35,8 @@ * | ||
| return (0, _removeAccents.default)(string) | ||
| // Convert  , &ndash, and &mdash to hyphens. | ||
| .replace(/( |–|—)/g, '-') | ||
| // Convert each group of whitespace, periods, and forward slashes to a hyphen. | ||
| .replace(/[\s\./]+/g, '-') | ||
| // Remove all HTML entities. | ||
| .replace(/&\S+?;/g, '') | ||
| // Remove anything that's not a letter, number, underscore or hyphen. | ||
@@ -39,0 +43,0 @@ .replace(/[^\p{L}\p{N}_-]+/gu, '') |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"names":["_removeAccents","_interopRequireDefault","require","cleanForSlug","string","removeAccents","replace","toLowerCase"],"sources":["@wordpress/url/src/clean-for-slug.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport removeAccents from 'remove-accents';\n\n/**\n * Performs some basic cleanup of a string for use as a post slug.\n *\n * This replicates some of what `sanitize_title()` does in WordPress core, but\n * is only designed to approximate what the slug will be.\n *\n * Converts Latin-1 Supplement and Latin Extended-A letters to basic Latin\n * letters. Removes combining diacritical marks. Converts whitespace, periods,\n * and forward slashes to hyphens. Removes any remaining non-word characters\n * except hyphens. Converts remaining string to lowercase. It does not account\n * for octets, HTML entities, or other encoded characters.\n *\n * @param {string} string Title or slug to be processed.\n *\n * @return {string} Processed string.\n */\nexport function cleanForSlug( string ) {\n\tif ( ! string ) {\n\t\treturn '';\n\t}\n\treturn (\n\t\tremoveAccents( string )\n\t\t\t// Convert each group of whitespace, periods, and forward slashes to a hyphen.\n\t\t\t.replace( /[\\s\\./]+/g, '-' )\n\t\t\t// Remove anything that's not a letter, number, underscore or hyphen.\n\t\t\t.replace( /[^\\p{L}\\p{N}_-]+/gu, '' )\n\t\t\t// Convert to lowercase\n\t\t\t.toLowerCase()\n\t\t\t// Replace multiple hyphens with a single one.\n\t\t\t.replace( /-+/g, '-' )\n\t\t\t// Remove any remaining leading or trailing hyphens.\n\t\t\t.replace( /(^-+)|(-+$)/g, '' )\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,cAAA,GAAAC,sBAAA,CAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,YAAYA,CAAEC,MAAM,EAAG;EACtC,IAAK,CAAEA,MAAM,EAAG;IACf,OAAO,EAAE;EACV;EACA,OACC,IAAAC,sBAAa,EAAED,MAAO;EACrB;EAAA,CACCE,OAAO,CAAE,WAAW,EAAE,GAAI;EAC3B;EAAA,CACCA,OAAO,CAAE,oBAAoB,EAAE,EAAG;EACnC;EAAA,CACCC,WAAW,CAAC;EACb;EAAA,CACCD,OAAO,CAAE,KAAK,EAAE,GAAI;EACrB;EAAA,CACCA,OAAO,CAAE,cAAc,EAAE,EAAG,CAAC;AAEjC","ignoreList":[]} | ||
| {"version":3,"names":["_removeAccents","_interopRequireDefault","require","cleanForSlug","string","removeAccents","replace","toLowerCase"],"sources":["@wordpress/url/src/clean-for-slug.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport removeAccents from 'remove-accents';\n\n/**\n * Performs some basic cleanup of a string for use as a post slug.\n *\n * This replicates some of what `sanitize_title_with_dashes()` does in WordPress core, but\n * is only designed to approximate what the slug will be.\n *\n * Converts Latin-1 Supplement and Latin Extended-A letters to basic Latin\n * letters. Removes combining diacritical marks. Converts whitespace, periods,\n * and forward slashes to hyphens. Removes any remaining non-word characters\n * except hyphens. Converts remaining string to lowercase. It does not account\n * for octets, HTML entities, or other encoded characters.\n *\n * @param {string} string Title or slug to be processed.\n *\n * @return {string} Processed string.\n */\nexport function cleanForSlug( string ) {\n\tif ( ! string ) {\n\t\treturn '';\n\t}\n\treturn (\n\t\tremoveAccents( string )\n\t\t\t// Convert  , &ndash, and &mdash to hyphens.\n\t\t\t.replace( /( |–|—)/g, '-' )\n\t\t\t// Convert each group of whitespace, periods, and forward slashes to a hyphen.\n\t\t\t.replace( /[\\s\\./]+/g, '-' )\n\t\t\t// Remove all HTML entities.\n\t\t\t.replace( /&\\S+?;/g, '' )\n\t\t\t// Remove anything that's not a letter, number, underscore or hyphen.\n\t\t\t.replace( /[^\\p{L}\\p{N}_-]+/gu, '' )\n\t\t\t// Convert to lowercase\n\t\t\t.toLowerCase()\n\t\t\t// Replace multiple hyphens with a single one.\n\t\t\t.replace( /-+/g, '-' )\n\t\t\t// Remove any remaining leading or trailing hyphens.\n\t\t\t.replace( /(^-+)|(-+$)/g, '' )\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,cAAA,GAAAC,sBAAA,CAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,YAAYA,CAAEC,MAAM,EAAG;EACtC,IAAK,CAAEA,MAAM,EAAG;IACf,OAAO,EAAE;EACV;EACA,OACC,IAAAC,sBAAa,EAAED,MAAO;EACrB;EAAA,CACCE,OAAO,CAAE,2BAA2B,EAAE,GAAI;EAC3C;EAAA,CACCA,OAAO,CAAE,WAAW,EAAE,GAAI;EAC3B;EAAA,CACCA,OAAO,CAAE,SAAS,EAAE,EAAG;EACxB;EAAA,CACCA,OAAO,CAAE,oBAAoB,EAAE,EAAG;EACnC;EAAA,CACCC,WAAW,CAAC;EACb;EAAA,CACCD,OAAO,CAAE,KAAK,EAAE,GAAI;EACrB;EAAA,CACCA,OAAO,CAAE,cAAc,EAAE,EAAG,CAAC;AAEjC","ignoreList":[]} |
+2
-2
| { | ||
| "name": "@wordpress/url", | ||
| "version": "4.19.1", | ||
| "version": "4.19.2", | ||
| "description": "WordPress URL utilities.", | ||
@@ -38,3 +38,3 @@ "author": "The WordPress Contributors", | ||
| }, | ||
| "gitHead": "6f49fee89f840761f7fedf662713cbd4a71723e9" | ||
| "gitHead": "018f5b628fb5006dd45a1b7cd63463c73bd9d641" | ||
| } |
+1
-1
@@ -71,3 +71,3 @@ # URL | ||
| This replicates some of what `sanitize_title()` does in WordPress core, but is only designed to approximate what the slug will be. | ||
| This replicates some of what `sanitize_title_with_dashes()` does in WordPress core, but is only designed to approximate what the slug will be. | ||
@@ -74,0 +74,0 @@ Converts Latin-1 Supplement and Latin Extended-A letters to basic Latin letters. Removes combining diacritical marks. Converts whitespace, periods, and forward slashes to hyphens. Removes any remaining non-word characters except hyphens. Converts remaining string to lowercase. It does not account for octets, HTML entities, or other encoded characters. |
@@ -9,3 +9,3 @@ /** | ||
| * | ||
| * This replicates some of what `sanitize_title()` does in WordPress core, but | ||
| * This replicates some of what `sanitize_title_with_dashes()` does in WordPress core, but | ||
| * is only designed to approximate what the slug will be. | ||
@@ -29,4 +29,8 @@ * | ||
| removeAccents( string ) | ||
| // Convert  , &ndash, and &mdash to hyphens. | ||
| .replace( /( |–|—)/g, '-' ) | ||
| // Convert each group of whitespace, periods, and forward slashes to a hyphen. | ||
| .replace( /[\s\./]+/g, '-' ) | ||
| // Remove all HTML entities. | ||
| .replace( /&\S+?;/g, '' ) | ||
| // Remove anything that's not a letter, number, underscore or hyphen. | ||
@@ -33,0 +37,0 @@ .replace( /[^\p{L}\p{N}_-]+/gu, '' ) |
+18
-0
@@ -1205,2 +1205,20 @@ /** | ||
| } ); | ||
| it( 'Should remove ampersands', () => { | ||
| expect( cleanForSlug( 'the long cat & dog' ) ).toBe( | ||
| 'the-long-cat-dog' | ||
| ); | ||
| expect( | ||
| cleanForSlug( 'the long cat & a dog && fish' ) | ||
| ).toBe( 'the-long-cat-a-dog-fish' ); | ||
| expect( cleanForSlug( 'the long cat & dog' ) ).toBe( | ||
| 'the-long-cat-amp-dog' | ||
| ); | ||
| } ); | ||
| it( 'Should remove HTML entities', () => { | ||
| expect( | ||
| cleanForSlug( 'No Entities> – Here —<' ) | ||
| ).toBe( 'no-entities-here' ); | ||
| } ); | ||
| } ); | ||
@@ -1207,0 +1225,0 @@ |
Sorry, the diff of this file is not supported yet
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
327747
0.48%4415
0.64%2
100%