()
| 1 | import { getStaticBuildInfo } from "./buildInfo"; |
| 2 | |
| 3 | function defaultDocsUrl(): string { |
| 4 | const docsUrl = "https://coder.com/docs"; |
| 5 | // If we can get the specific version, we want to include that in default docs URL. |
| 6 | let version = getStaticBuildInfo()?.version; |
| 7 | if (!version) { |
| 8 | return docsUrl; |
| 9 | } |
| 10 | |
| 11 | // Strip build metadata after '+', then remove a '-devel' suffix |
| 12 | // if present. Preserve '-rc.X' suffixes so versioned docs links |
| 13 | // point at the correct release candidate. |
| 14 | version = version.split("+")[0].replace(/-devel$/, ""); |
| 15 | if (version === "v0.0.0") { |
| 16 | return docsUrl; |
| 17 | } |
| 18 | return `${docsUrl}/@${version}`; |
| 19 | } |
| 20 | |
| 21 | // Add cache to avoid DOM reading all the time |
| 22 | let CACHED_DOCS_URL: string | undefined; |
no test coverage detected