rsshub
Version:
Make RSS Great Again!
22 lines (20 loc) • 711 B
JavaScript
import { t as parseDate } from "./parse-date-BrP7mxXf.mjs";
import title from "title";
//#region lib/utils/common-utils.ts
const toTitleCase = (str) => title(str);
const rWhiteSpace = /\s+/;
const rAllWhiteSpace = /\s+/g;
const collapseWhitespace = (str) => {
if (str && rWhiteSpace.test(str)) return str.replaceAll(rAllWhiteSpace, " ").trim();
return str;
};
const convertDateToISO8601 = (date) => {
if (!date) return date;
if (typeof date !== "object") date = parseDate(date);
return date.toISOString();
};
const getSubPath = (ctx) => {
return ctx.req.path.replace(/\/[^/]*/, "") || "/";
};
//#endregion
export { toTitleCase as i, convertDateToISO8601 as n, getSubPath as r, collapseWhitespace as t };