Add existing to tracked

This commit is contained in:
Jay
2026-08-11 09:53:42 -04:00
parent afe07f3055
commit ffd6e3d73c
8531 changed files with 4396230 additions and 0 deletions
+9
View File
@@ -0,0 +1,9 @@
/**
* A truncation feature where the ellipsis will be placed at the end of the URL.
*
* @param {String} anchorText
* @param {Number} truncateLen The maximum length of the truncated output URL string.
* @param {String} ellipsisChars The characters to place within the url, e.g. "..".
* @return {String} The truncated URL.
*/
export declare function truncateEnd(anchorText: string, truncateLen: number, ellipsisChars?: string): string;
+13
View File
@@ -0,0 +1,13 @@
import { ellipsis } from '../utils';
/**
* A truncation feature where the ellipsis will be placed at the end of the URL.
*
* @param {String} anchorText
* @param {Number} truncateLen The maximum length of the truncated output URL string.
* @param {String} ellipsisChars The characters to place within the url, e.g. "..".
* @return {String} The truncated URL.
*/
export function truncateEnd(anchorText, truncateLen, ellipsisChars) {
return ellipsis(anchorText, truncateLen, ellipsisChars);
}
//# sourceMappingURL=truncate-end.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"truncate-end.js","sourceRoot":"","sources":["../../../src/truncate/truncate-end.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CAAC,UAAkB,EAAE,WAAmB,EAAE,aAAsB;IACvF,OAAO,QAAQ,CAAC,UAAU,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC;AAC5D,CAAC","sourcesContent":["import { ellipsis } from '../utils';\n\n/**\n * A truncation feature where the ellipsis will be placed at the end of the URL.\n *\n * @param {String} anchorText\n * @param {Number} truncateLen The maximum length of the truncated output URL string.\n * @param {String} ellipsisChars The characters to place within the url, e.g. \"..\".\n * @return {String} The truncated URL.\n */\nexport function truncateEnd(anchorText: string, truncateLen: number, ellipsisChars?: string) {\n return ellipsis(anchorText, truncateLen, ellipsisChars);\n}\n"]}
+12
View File
@@ -0,0 +1,12 @@
/**
* Date: 2015-10-05
* Author: Kasper Søfren <soefritz@gmail.com> (https://github.com/kafoso)
*
* A truncation feature, where the ellipsis will be placed in the dead-center of the URL.
*
* @param {String} url A URL.
* @param {Number} truncateLen The maximum length of the truncated output URL string.
* @param {String} ellipsisChars The characters to place within the url, e.g. "..".
* @return {String} The truncated URL.
*/
export declare function truncateMiddle(url: string, truncateLen: number, ellipsisChars?: string): string;
+34
View File
@@ -0,0 +1,34 @@
/**
* Date: 2015-10-05
* Author: Kasper Søfren <soefritz@gmail.com> (https://github.com/kafoso)
*
* A truncation feature, where the ellipsis will be placed in the dead-center of the URL.
*
* @param {String} url A URL.
* @param {Number} truncateLen The maximum length of the truncated output URL string.
* @param {String} ellipsisChars The characters to place within the url, e.g. "..".
* @return {String} The truncated URL.
*/
export function truncateMiddle(url, truncateLen, ellipsisChars) {
if (url.length <= truncateLen) {
return url;
}
var ellipsisLengthBeforeParsing;
var ellipsisLength;
if (ellipsisChars == null) {
ellipsisChars = '&hellip;';
ellipsisLengthBeforeParsing = 8;
ellipsisLength = 3;
}
else {
ellipsisLengthBeforeParsing = ellipsisChars.length;
ellipsisLength = ellipsisChars.length;
}
var availableLength = truncateLen - ellipsisLength;
var end = '';
if (availableLength > 0) {
end = url.substr(-1 * Math.floor(availableLength / 2));
}
return (url.substr(0, Math.ceil(availableLength / 2)) + ellipsisChars + end).substr(0, availableLength + ellipsisLengthBeforeParsing);
}
//# sourceMappingURL=truncate-middle.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"truncate-middle.js","sourceRoot":"","sources":["../../../src/truncate/truncate-middle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,WAAmB,EAAE,aAAsB;IACnF,IAAI,GAAG,CAAC,MAAM,IAAI,WAAW,EAAE,CAAC;QAC5B,OAAO,GAAG,CAAC;IACf,CAAC;IAED,IAAI,2BAAmC,CAAC;IACxC,IAAI,cAAsB,CAAC;IAE3B,IAAI,aAAa,IAAI,IAAI,EAAE,CAAC;QACxB,aAAa,GAAG,UAAU,CAAC;QAC3B,2BAA2B,GAAG,CAAC,CAAC;QAChC,cAAc,GAAG,CAAC,CAAC;IACvB,CAAC;SAAM,CAAC;QACJ,2BAA2B,GAAG,aAAa,CAAC,MAAM,CAAC;QACnD,cAAc,GAAG,aAAa,CAAC,MAAM,CAAC;IAC1C,CAAC;IAED,IAAM,eAAe,GAAG,WAAW,GAAG,cAAc,CAAC;IACrD,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,IAAI,eAAe,GAAG,CAAC,EAAE,CAAC;QACtB,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,GAAG,CAAC,CAAC,CAAC,CAAC;IAC3D,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,eAAe,GAAG,CAAC,CAAC,CAAC,GAAG,aAAa,GAAG,GAAG,CAAC,CAAC,MAAM,CAC/E,CAAC,EACD,eAAe,GAAG,2BAA2B,CAChD,CAAC;AACN,CAAC","sourcesContent":["/**\n * Date: 2015-10-05\n * Author: Kasper Søfren <soefritz@gmail.com> (https://github.com/kafoso)\n *\n * A truncation feature, where the ellipsis will be placed in the dead-center of the URL.\n *\n * @param {String} url A URL.\n * @param {Number} truncateLen The maximum length of the truncated output URL string.\n * @param {String} ellipsisChars The characters to place within the url, e.g. \"..\".\n * @return {String} The truncated URL.\n */\nexport function truncateMiddle(url: string, truncateLen: number, ellipsisChars?: string) {\n if (url.length <= truncateLen) {\n return url;\n }\n\n let ellipsisLengthBeforeParsing: number;\n let ellipsisLength: number;\n\n if (ellipsisChars == null) {\n ellipsisChars = '&hellip;';\n ellipsisLengthBeforeParsing = 8;\n ellipsisLength = 3;\n } else {\n ellipsisLengthBeforeParsing = ellipsisChars.length;\n ellipsisLength = ellipsisChars.length;\n }\n\n const availableLength = truncateLen - ellipsisLength;\n let end = '';\n if (availableLength > 0) {\n end = url.substr(-1 * Math.floor(availableLength / 2));\n }\n return (url.substr(0, Math.ceil(availableLength / 2)) + ellipsisChars + end).substr(\n 0,\n availableLength + ellipsisLengthBeforeParsing\n );\n}\n"]}
+13
View File
@@ -0,0 +1,13 @@
/**
* Date: 2015-10-05
* Author: Kasper Søfren <soefritz@gmail.com> (https://github.com/kafoso)
*
* A truncation feature, where the ellipsis will be placed at a section within
* the URL making it still somewhat human readable.
*
* @param {String} url A URL.
* @param {Number} truncateLen The maximum length of the truncated output URL string.
* @param {String} ellipsisChars The characters to place within the url, e.g. "...".
* @return {String} The truncated URL.
*/
export declare function truncateSmart(url: string, truncateLen: number, ellipsisChars?: string): string;
+181
View File
@@ -0,0 +1,181 @@
/**
* Date: 2015-10-05
* Author: Kasper Søfren <soefritz@gmail.com> (https://github.com/kafoso)
*
* A truncation feature, where the ellipsis will be placed at a section within
* the URL making it still somewhat human readable.
*
* @param {String} url A URL.
* @param {Number} truncateLen The maximum length of the truncated output URL string.
* @param {String} ellipsisChars The characters to place within the url, e.g. "...".
* @return {String} The truncated URL.
*/
export function truncateSmart(url, truncateLen, ellipsisChars) {
var ellipsisLengthBeforeParsing;
var ellipsisLength;
if (ellipsisChars == null) {
ellipsisChars = '&hellip;';
ellipsisLength = 3;
ellipsisLengthBeforeParsing = 8;
}
else {
ellipsisLength = ellipsisChars.length;
ellipsisLengthBeforeParsing = ellipsisChars.length;
}
// If the URL is shorter than the truncate length, return it as is
if (url.length <= truncateLen) {
return url;
}
var availableLength = truncateLen - ellipsisLength;
var urlObj = parseUrl(url);
// Clean up the URL by removing any malformed query string
// (e.g. "?foo=bar?ignorethis")
if (urlObj.query) {
var matchQuery = urlObj.query.match(/^(.*?)(?=(\?|#))(.*?)$/i);
if (matchQuery) {
// Malformed URL; two or more "?". Removed any content behind the 2nd.
urlObj.query = urlObj.query.substr(0, matchQuery[1].length);
url = buildUrl(urlObj);
}
}
if (url.length <= truncateLen) {
return url; // removing a malformed query string brought the URL under the truncateLength
}
// Clean up the URL by removing 'www.' from the host if it exists
if (urlObj.host) {
urlObj.host = urlObj.host.replace(/^www\./, '');
url = buildUrl(urlObj);
}
if (url.length <= truncateLen) {
return url; // removing 'www.' brought the URL under the truncateLength
}
// Process and build the truncated URL, starting with the hostname
var truncatedUrl = '';
if (urlObj.host) {
truncatedUrl += urlObj.host;
}
if (truncatedUrl.length >= availableLength) {
if (urlObj.host.length === truncateLen) {
return (urlObj.host.substr(0, truncateLen - ellipsisLength) + ellipsisChars).substr(0, availableLength + ellipsisLengthBeforeParsing);
}
return buildSegment(truncatedUrl, availableLength, ellipsisChars).substr(0, availableLength + ellipsisLengthBeforeParsing);
}
// If we still have available chars left, add the path and query string
var pathAndQuery = '';
if (urlObj.path) {
pathAndQuery += '/' + urlObj.path;
}
if (urlObj.query) {
pathAndQuery += '?' + urlObj.query;
}
if (pathAndQuery) {
if ((truncatedUrl + pathAndQuery).length >= availableLength) {
if ((truncatedUrl + pathAndQuery).length == truncateLen) {
return (truncatedUrl + pathAndQuery).substr(0, truncateLen);
}
var remainingAvailableLength = availableLength - truncatedUrl.length;
return (truncatedUrl + buildSegment(pathAndQuery, remainingAvailableLength, ellipsisChars)).substr(0, availableLength + ellipsisLengthBeforeParsing);
}
else {
truncatedUrl += pathAndQuery;
}
}
// If we still have available chars left, add the fragment
if (urlObj.fragment) {
var fragment = '#' + urlObj.fragment;
if ((truncatedUrl + fragment).length >= availableLength) {
if ((truncatedUrl + fragment).length == truncateLen) {
return (truncatedUrl + fragment).substr(0, truncateLen);
}
var remainingAvailableLength2 = availableLength - truncatedUrl.length;
return (truncatedUrl + buildSegment(fragment, remainingAvailableLength2, ellipsisChars)).substr(0, availableLength + ellipsisLengthBeforeParsing);
}
else {
truncatedUrl += fragment;
}
}
// If we still have available chars left, add the scheme
if (urlObj.scheme && urlObj.host) {
var scheme = urlObj.scheme + '://';
if ((truncatedUrl + scheme).length < availableLength) {
return (scheme + truncatedUrl).substr(0, truncateLen);
}
}
if (truncatedUrl.length <= truncateLen) {
return truncatedUrl;
}
var end = '';
if (availableLength > 0) {
end = truncatedUrl.substr(-1 * Math.floor(availableLength / 2));
}
return (truncatedUrl.substr(0, Math.ceil(availableLength / 2)) + ellipsisChars + end).substr(0, availableLength + ellipsisLengthBeforeParsing);
}
/**
* Parses a URL into its components: scheme, host, path, query, and fragment.
*/
function parseUrl(url) {
// Functionality inspired by PHP function of same name
var urlObj = {};
var urlSub = url;
// Parse scheme
var match = urlSub.match(/^([a-z]+):\/\//i);
if (match) {
urlObj.scheme = match[1];
urlSub = urlSub.slice(match[0].length);
}
// Parse host
match = urlSub.match(/^(.*?)(?=(\?|#|\/|$))/i);
if (match) {
urlObj.host = match[1];
urlSub = urlSub.slice(match[0].length);
}
// Parse path
match = urlSub.match(/^\/(.*?)(?=(\?|#|$))/i);
if (match) {
urlObj.path = match[1];
urlSub = urlSub.slice(match[0].length);
}
// Parse query
match = urlSub.match(/^\?(.*?)(?=(#|$))/i);
if (match) {
urlObj.query = match[1];
urlSub = urlSub.slice(match[0].length);
}
// Parse fragment
match = urlSub.match(/^#(.*?)$/i);
if (match) {
urlObj.fragment = match[1];
//urlSub = urlSub.slice(match[0].length); -- not used. Uncomment if adding another block.
}
return urlObj;
}
function buildUrl(urlObj) {
var url = '';
if (urlObj.scheme && urlObj.host) {
url += urlObj.scheme + '://';
}
if (urlObj.host) {
url += urlObj.host;
}
if (urlObj.path) {
url += '/' + urlObj.path;
}
if (urlObj.query) {
url += '?' + urlObj.query;
}
if (urlObj.fragment) {
url += '#' + urlObj.fragment;
}
return url;
}
function buildSegment(segment, remainingAvailableLength, ellipsisChars) {
var remainingAvailableLengthHalf = remainingAvailableLength / 2;
var startOffset = Math.ceil(remainingAvailableLengthHalf);
var endOffset = -1 * Math.floor(remainingAvailableLengthHalf);
var end = '';
if (endOffset < 0) {
end = segment.substr(endOffset);
}
return segment.substr(0, startOffset) + ellipsisChars + end;
}
//# sourceMappingURL=truncate-smart.js.map
File diff suppressed because one or more lines are too long