mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-12 05:48:57 +00:00
5a5b4bb93c
* Replace Puppeteer by Playwright * Remove the limit of workers on ci * Various fixes after review * Document things
31 lines
757 B
TypeScript
31 lines
757 B
TypeScript
/**
|
|
* Get the target URL from the command line arguments.
|
|
*/
|
|
export function getTargetURL() {
|
|
const targetUrl = Bun.argv[2];
|
|
if (!targetUrl) {
|
|
console.error('No target URL provided');
|
|
process.exit(1);
|
|
}
|
|
|
|
return targetUrl;
|
|
}
|
|
|
|
export function getContentPathName(input: string): string {
|
|
const contentUrl = new URL(input);
|
|
return `${contentUrl.host}${contentUrl.pathname}`;
|
|
}
|
|
|
|
/**
|
|
* Get the URL to load for a content
|
|
*/
|
|
export function getContentTestURL(input: string, baseUrl: string = getTargetURL()): string {
|
|
const url = new URL(baseUrl);
|
|
const contentUrl = new URL(input);
|
|
|
|
url.pathname = `${contentUrl.host}${contentUrl.pathname}`;
|
|
url.search = contentUrl.search;
|
|
|
|
return url.toString();
|
|
}
|