Files
RSSHub/lib/routes/swpu/utils.ts
T
Tony 75d43dd086 chore: add eslint-plugin-regexp (#22189)
* chore: add eslint-plugin-regexp

* chore: autofix

* chore: fix no-useless-flag

* chore: fix optimal-lookaround-quantifier

* chore: fix no-lazy-ends

* chore: fix no-contradiction-with-assertion

* chore: fix no-useless-assertions

* chore: fix no-useless-quantifier

* chore: fix remaining regexp issues

* fix: regex for WFU news link validation
2026-06-05 20:04:39 +08:00

21 lines
342 B
TypeScript

function isCompleteUrl(url) {
return /^\w+:\/\/.*?\//.test(url);
}
function joinUrl(url1, url2) {
if (isCompleteUrl(url2)) {
return url2;
}
if (!url1.endsWith('/')) {
url1 = url1 + '/';
}
if (url2.startsWith('/')) {
url2 = url2.slice(1);
}
return url1 + url2;
}
export { joinUrl };