@mintlify/common 1.0.1333 → 1.0.1335

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.
@@ -0,0 +1,11 @@
1
+ type GithubInstallationMatch = {
2
+ owner: string;
3
+ isSelfHosted?: boolean;
4
+ hostUrl?: string;
5
+ };
6
+ export declare function normalizeGithubHostUrl(hostUrl: string): string;
7
+ export declare function findGithubInstallation<T extends GithubInstallationMatch>(installations: T[], { owner, hostUrl }: {
8
+ owner: string;
9
+ hostUrl?: string;
10
+ }): T | undefined;
11
+ export {};
@@ -0,0 +1,19 @@
1
+ export function normalizeGithubHostUrl(hostUrl) {
2
+ try {
3
+ return new URL(hostUrl).origin;
4
+ }
5
+ catch (_a) {
6
+ return hostUrl.toLowerCase();
7
+ }
8
+ }
9
+ export function findGithubInstallation(installations, { owner, hostUrl }) {
10
+ var _a;
11
+ const matches = installations.filter((installation) => installation.owner.toLowerCase() === owner.toLowerCase());
12
+ if (hostUrl) {
13
+ const host = normalizeGithubHostUrl(hostUrl);
14
+ return matches.find((installation) => installation.isSelfHosted &&
15
+ installation.hostUrl !== undefined &&
16
+ normalizeGithubHostUrl(installation.hostUrl) === host);
17
+ }
18
+ return (_a = matches.find((installation) => !installation.isSelfHosted)) !== null && _a !== void 0 ? _a : matches[0];
19
+ }
package/dist/index.d.ts CHANGED
@@ -31,6 +31,7 @@ export * from './strip-markdown.js';
31
31
  export * from './api-reference/parseApiTargetFromMetadata.js';
32
32
  export * from './mintIgnore.js';
33
33
  export * from './getDisplayDomain.js';
34
+ export * from './githubInstallations.js';
34
35
  export * from './getRelativeRecordName.js';
35
36
  export * from './apiStaticExportBasePaths.js';
36
37
  export * from './basePaths.js';
package/dist/index.js CHANGED
@@ -31,6 +31,7 @@ export * from './strip-markdown.js';
31
31
  export * from './api-reference/parseApiTargetFromMetadata.js';
32
32
  export * from './mintIgnore.js';
33
33
  export * from './getDisplayDomain.js';
34
+ export * from './githubInstallations.js';
34
35
  export * from './getRelativeRecordName.js';
35
36
  export * from './apiStaticExportBasePaths.js';
36
37
  export * from './basePaths.js';