mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 08:23:34 +00:00
19 lines
377 B
TypeScript
19 lines
377 B
TypeScript
/**
|
|
* Adds a markdown extension to the URL according to the
|
|
* [llms.txt](https://llmstxt.org/) specification.
|
|
*/
|
|
export function llmstxtUrl(url: URL | string): URL {
|
|
url = new URL(url);
|
|
|
|
if (url.pathname.endsWith('.md')) {
|
|
return url;
|
|
}
|
|
|
|
if (url.pathname.endsWith('/')) {
|
|
url.pathname += 'index.md';
|
|
} else {
|
|
url.pathname += '.md';
|
|
}
|
|
|
|
return url;
|
|
} |