@mintlify/common 1.0.825 → 1.0.827
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -3,5 +3,9 @@ export type DisplayDomainDeployment = {
|
|
|
3
3
|
basePath: string;
|
|
4
4
|
customDomains?: string[];
|
|
5
5
|
auth?: unknown;
|
|
6
|
+
atlas?: {
|
|
7
|
+
id: string;
|
|
8
|
+
repoUrl?: string;
|
|
9
|
+
};
|
|
6
10
|
};
|
|
7
11
|
export declare function getDisplayDomain(deployment: DisplayDomainDeployment, isDev?: boolean, appendBasePath?: boolean): string;
|
package/dist/getDisplayDomain.js
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
function parseOwnerRepo(repoUrl) {
|
|
2
|
+
const patterns = [
|
|
3
|
+
/^https?:\/\/github\.com\/([^/]+)\/([^/]+?)(?:\.git)?(?:\/|$)/,
|
|
4
|
+
/^github\.com\/([^/]+)\/([^/]+?)(?:\.git)?$/,
|
|
5
|
+
/^([^/]+)\/([^/]+)$/,
|
|
6
|
+
];
|
|
7
|
+
for (const pattern of patterns) {
|
|
8
|
+
const match = repoUrl.match(pattern);
|
|
9
|
+
if ((match === null || match === void 0 ? void 0 : match[1]) && match[2]) {
|
|
10
|
+
return { owner: match[1], repo: match[2].replace(/\.git$/, '') };
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
1
15
|
const CUSTOM_DEPLOYMENT_SUBDOMAINS = ['auth0', 'docs-dev', 'docs-staging'];
|
|
2
16
|
const CUSTOM_DEPLOYMENT_DOMAINS = {
|
|
3
17
|
auth0: 'auth0-mintlify.app',
|
|
@@ -47,11 +61,17 @@ function getSubdomain(deployment) {
|
|
|
47
61
|
}
|
|
48
62
|
}
|
|
49
63
|
export function getDisplayDomain(deployment, isDev = false, appendBasePath = true) {
|
|
50
|
-
var _a, _b, _c;
|
|
64
|
+
var _a, _b, _c, _d;
|
|
51
65
|
const { subdomain } = deployment;
|
|
52
|
-
if (
|
|
66
|
+
if ((_a = deployment.atlas) === null || _a === void 0 ? void 0 : _a.repoUrl) {
|
|
67
|
+
const parsed = parseOwnerRepo(deployment.atlas.repoUrl);
|
|
68
|
+
if (parsed) {
|
|
69
|
+
return `mintlify.com/${parsed.owner}/${parsed.repo}`;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (isDev && !((_b = deployment.customDomains) === null || _b === void 0 ? void 0 : _b[0])) {
|
|
53
73
|
return `${subdomain}.mintlifytest.com`;
|
|
54
74
|
}
|
|
55
|
-
const displayDomainBase = (
|
|
75
|
+
const displayDomainBase = (_d = (_c = deployment.customDomains) === null || _c === void 0 ? void 0 : _c[0]) !== null && _d !== void 0 ? _d : `${subdomain}.${getSubdomain(deployment)}`;
|
|
56
76
|
return displayDomainBase + (appendBasePath ? deployment.basePath : '');
|
|
57
77
|
}
|