- Move external URL checks to its own module under `tests/`. This separates them from integration test, addressing long runs and frequent failures that led to ignoring test results. - Move `check-desktop-runtime-errors` to `tests/checks` to keep all test-related checks into one directory. - Replace `ts-node` with `vite` for running `check-desktop-runtime-errors` to maintain a consistent execution environment across checks. - Implement a timeout for each fetch call. - Be nice to external sources, wait 5 seconds before sending another request to an URL under same domain. This solves rate-limiting issues. - Instead of running test on every push/pull request, run them only weekly. - Do not run tests on each commit/PR but only scheduled (weekly) to minimize noise. - Fix URLs are not captured correctly inside backticks or parenthesis.
20 lines
530 B
TypeScript
20 lines
530 B
TypeScript
export function groupUrlsByDomain(urls: string[]): string[][] {
|
|
const domains = new Set<string>();
|
|
const urlsWithDomain = urls.map((url) => ({
|
|
url,
|
|
domain: extractDomain(url),
|
|
}));
|
|
for (const url of urlsWithDomain) {
|
|
domains.add(url.domain);
|
|
}
|
|
return Array.from(domains).map((domain) => {
|
|
return urlsWithDomain
|
|
.filter((url) => url.domain === domain)
|
|
.map((url) => url.url);
|
|
});
|
|
}
|
|
|
|
function extractDomain(url: string): string {
|
|
return url.split('://')[1].split('/')[0].toLowerCase();
|
|
}
|