@wordpress/url 4.48.1 → 4.48.2-next.v.202606191442.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.
|
@@ -39,7 +39,7 @@ function filterURLForDisplay(url, maxLength = null) {
|
|
|
39
39
|
const urlPieces = filteredURL.split("/");
|
|
40
40
|
const file = urlPieces[urlPieces.length - 1];
|
|
41
41
|
if (file.length <= maxLength) {
|
|
42
|
-
return "
|
|
42
|
+
return "…" + filteredURL.slice(-maxLength);
|
|
43
43
|
}
|
|
44
44
|
const index = file.lastIndexOf(".");
|
|
45
45
|
const [fileName, extension] = [
|
|
@@ -47,7 +47,7 @@ function filterURLForDisplay(url, maxLength = null) {
|
|
|
47
47
|
file.slice(index + 1)
|
|
48
48
|
];
|
|
49
49
|
const truncatedFile = fileName.slice(-3) + "." + extension;
|
|
50
|
-
return file.slice(0, maxLength - truncatedFile.length - 1) + "
|
|
50
|
+
return file.slice(0, maxLength - truncatedFile.length - 1) + "…" + truncatedFile;
|
|
51
51
|
}
|
|
52
52
|
// Annotate the CommonJS export names for ESM import in node:
|
|
53
53
|
0 && (module.exports = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/filter-url-for-display.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Returns a URL for display.\n *\n * @param url Original URL.\n * @param 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 ); //
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAcO,SAAS,oBACf,KACA,YAA2B,MAClB;AACT,MAAK,CAAE,KAAM;AACZ,WAAO;AAAA,EACR;AAGA,MAAI,cAAc,IAChB,QAAS,+BAA+B,EAAG,EAC3C,QAAS,WAAW,EAAG;AAGzB,MAAK,YAAY,MAAO,YAAa,GAAI;AACxC,kBAAc,YAAY,QAAS,KAAK,EAAG;AAAA,EAC5C;AAGA,QAAM,aAAa;AAEnB,MACC,CAAE,aACF,YAAY,UAAU,aACtB,CAAE,YAAY,MAAO,UAAW,GAC/B;AACD,WAAO;AAAA,EACR;AAGA,gBAAc,YAAY,MAAO,GAAI,EAAG,CAAE;AAC1C,QAAM,YAAY,YAAY,MAAO,GAAI;AACzC,QAAM,OAAO,UAAW,UAAU,SAAS,CAAE;AAC7C,MAAK,KAAK,UAAU,WAAY;AAC/B,WAAO,
|
|
4
|
+
"sourcesContent": ["/**\n * Returns a URL for display.\n *\n * @param url Original URL.\n * @param 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 Displayed URL.\n */\nexport function filterURLForDisplay(\n\turl: string,\n\tmaxLength: number | null = null\n): string {\n\tif ( ! url ) {\n\t\treturn '';\n\t}\n\n\t// Remove protocol and www prefixes.\n\tlet filteredURL = url\n\t\t.replace( /^[a-z\\-.\\+]+[0-9]*:(\\/\\/)?/i, '' )\n\t\t.replace( /^www\\./i, '' );\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\t// capture file name from URL\n\tconst fileRegexp = /\\/([^\\/?]+)\\.(?:[\\w]+)(?=\\?|$)/;\n\n\tif (\n\t\t! maxLength ||\n\t\tfilteredURL.length <= maxLength ||\n\t\t! filteredURL.match( fileRegexp )\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"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAcO,SAAS,oBACf,KACA,YAA2B,MAClB;AACT,MAAK,CAAE,KAAM;AACZ,WAAO;AAAA,EACR;AAGA,MAAI,cAAc,IAChB,QAAS,+BAA+B,EAAG,EAC3C,QAAS,WAAW,EAAG;AAGzB,MAAK,YAAY,MAAO,YAAa,GAAI;AACxC,kBAAc,YAAY,QAAS,KAAK,EAAG;AAAA,EAC5C;AAGA,QAAM,aAAa;AAEnB,MACC,CAAE,aACF,YAAY,UAAU,aACtB,CAAE,YAAY,MAAO,UAAW,GAC/B;AACD,WAAO;AAAA,EACR;AAGA,gBAAc,YAAY,MAAO,GAAI,EAAG,CAAE;AAC1C,QAAM,YAAY,YAAY,MAAO,GAAI;AACzC,QAAM,OAAO,UAAW,UAAU,SAAS,CAAE;AAC7C,MAAK,KAAK,UAAU,WAAY;AAC/B,WAAO,MAAM,YAAY,MAAO,CAAC,SAAU;AAAA,EAC5C;AAGA,QAAM,QAAQ,KAAK,YAAa,GAAI;AACpC,QAAM,CAAE,UAAU,SAAU,IAAI;AAAA,IAC/B,KAAK,MAAO,GAAG,KAAM;AAAA,IACrB,KAAK,MAAO,QAAQ,CAAE;AAAA,EACvB;AACA,QAAM,gBAAgB,SAAS,MAAO,EAAG,IAAI,MAAM;AACnD,SACC,KAAK,MAAO,GAAG,YAAY,cAAc,SAAS,CAAE,IACpD,MACA;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -15,7 +15,7 @@ function filterURLForDisplay(url, maxLength = null) {
|
|
|
15
15
|
const urlPieces = filteredURL.split("/");
|
|
16
16
|
const file = urlPieces[urlPieces.length - 1];
|
|
17
17
|
if (file.length <= maxLength) {
|
|
18
|
-
return "
|
|
18
|
+
return "…" + filteredURL.slice(-maxLength);
|
|
19
19
|
}
|
|
20
20
|
const index = file.lastIndexOf(".");
|
|
21
21
|
const [fileName, extension] = [
|
|
@@ -23,7 +23,7 @@ function filterURLForDisplay(url, maxLength = null) {
|
|
|
23
23
|
file.slice(index + 1)
|
|
24
24
|
];
|
|
25
25
|
const truncatedFile = fileName.slice(-3) + "." + extension;
|
|
26
|
-
return file.slice(0, maxLength - truncatedFile.length - 1) + "
|
|
26
|
+
return file.slice(0, maxLength - truncatedFile.length - 1) + "…" + truncatedFile;
|
|
27
27
|
}
|
|
28
28
|
export {
|
|
29
29
|
filterURLForDisplay
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/filter-url-for-display.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Returns a URL for display.\n *\n * @param url Original URL.\n * @param 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 ); //
|
|
5
|
-
"mappings": ";AAcO,SAAS,oBACf,KACA,YAA2B,MAClB;AACT,MAAK,CAAE,KAAM;AACZ,WAAO;AAAA,EACR;AAGA,MAAI,cAAc,IAChB,QAAS,+BAA+B,EAAG,EAC3C,QAAS,WAAW,EAAG;AAGzB,MAAK,YAAY,MAAO,YAAa,GAAI;AACxC,kBAAc,YAAY,QAAS,KAAK,EAAG;AAAA,EAC5C;AAGA,QAAM,aAAa;AAEnB,MACC,CAAE,aACF,YAAY,UAAU,aACtB,CAAE,YAAY,MAAO,UAAW,GAC/B;AACD,WAAO;AAAA,EACR;AAGA,gBAAc,YAAY,MAAO,GAAI,EAAG,CAAE;AAC1C,QAAM,YAAY,YAAY,MAAO,GAAI;AACzC,QAAM,OAAO,UAAW,UAAU,SAAS,CAAE;AAC7C,MAAK,KAAK,UAAU,WAAY;AAC/B,WAAO,
|
|
4
|
+
"sourcesContent": ["/**\n * Returns a URL for display.\n *\n * @param url Original URL.\n * @param 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 Displayed URL.\n */\nexport function filterURLForDisplay(\n\turl: string,\n\tmaxLength: number | null = null\n): string {\n\tif ( ! url ) {\n\t\treturn '';\n\t}\n\n\t// Remove protocol and www prefixes.\n\tlet filteredURL = url\n\t\t.replace( /^[a-z\\-.\\+]+[0-9]*:(\\/\\/)?/i, '' )\n\t\t.replace( /^www\\./i, '' );\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\t// capture file name from URL\n\tconst fileRegexp = /\\/([^\\/?]+)\\.(?:[\\w]+)(?=\\?|$)/;\n\n\tif (\n\t\t! maxLength ||\n\t\tfilteredURL.length <= maxLength ||\n\t\t! filteredURL.match( fileRegexp )\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"],
|
|
5
|
+
"mappings": ";AAcO,SAAS,oBACf,KACA,YAA2B,MAClB;AACT,MAAK,CAAE,KAAM;AACZ,WAAO;AAAA,EACR;AAGA,MAAI,cAAc,IAChB,QAAS,+BAA+B,EAAG,EAC3C,QAAS,WAAW,EAAG;AAGzB,MAAK,YAAY,MAAO,YAAa,GAAI;AACxC,kBAAc,YAAY,QAAS,KAAK,EAAG;AAAA,EAC5C;AAGA,QAAM,aAAa;AAEnB,MACC,CAAE,aACF,YAAY,UAAU,aACtB,CAAE,YAAY,MAAO,UAAW,GAC/B;AACD,WAAO;AAAA,EACR;AAGA,gBAAc,YAAY,MAAO,GAAI,EAAG,CAAE;AAC1C,QAAM,YAAY,YAAY,MAAO,GAAI;AACzC,QAAM,OAAO,UAAW,UAAU,SAAS,CAAE;AAC7C,MAAK,KAAK,UAAU,WAAY;AAC/B,WAAO,MAAM,YAAY,MAAO,CAAC,SAAU;AAAA,EAC5C;AAGA,QAAM,QAAQ,KAAK,YAAa,GAAI;AACpC,QAAM,CAAE,UAAU,SAAU,IAAI;AAAA,IAC/B,KAAK,MAAO,GAAG,KAAM;AAAA,IACrB,KAAK,MAAO,QAAQ,CAAE;AAAA,EACvB;AACA,QAAM,gBAAgB,SAAS,MAAO,EAAG,IAAI,MAAM;AACnD,SACC,KAAK,MAAO,GAAG,YAAY,cAAc,SAAS,CAAE,IACpD,MACA;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/url",
|
|
3
|
-
"version": "4.48.
|
|
3
|
+
"version": "4.48.2-next.v.202606191442.0+17fe7db8a",
|
|
4
4
|
"description": "WordPress URL utilities.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"publishConfig": {
|
|
49
49
|
"access": "public"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "1b6a19222df5a88f161880b5789efb3171d8f425"
|
|
52
52
|
}
|