@mintlify/previewing 4.0.1542 → 4.0.1544

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.
@@ -66,6 +66,11 @@ describe('export assets', () => {
66
66
  ...(await fse.readFile(path.join(exportDir, '_mintlify/export-assets/fonts.gstatic.com/s/a.woff2'))),
67
67
  ]).toEqual([1, 2, 3]);
68
68
  });
69
+ it('does not report missing language icons as failed', async () => {
70
+ await fse.outputFile(path.join(exportDir, 'index.html'), '<pre language="sql"></pre><pre language="python"></pre>');
71
+ const result = await localizeAssets(exportDir, async () => undefined);
72
+ expect(result.failed).toEqual([]);
73
+ });
69
74
  });
70
75
  describe('localizeAssets path safety', () => {
71
76
  let exportDir;
@@ -1,4 +1,4 @@
1
- import { MINT_EXPORT_ASSETS_PREFIX, fromMintExportAssetPath, getLanguageIconUrl, toMintExportAssetPath, } from '@mintlify/common';
1
+ import { MINT_EXPORT_ASSETS_PREFIX, MINTLIFY_ICONS_CDN_URL, fromMintExportAssetPath, getLanguageIconUrl, toMintExportAssetPath, } from '@mintlify/common';
2
2
  import fse from 'fs-extra';
3
3
  import path from 'path';
4
4
  import { fetchPublicAsset } from './export-fetch.js';
@@ -6,6 +6,7 @@ const ASSET_PATH_PATTERN = new RegExp(`${MINT_EXPORT_ASSETS_PREFIX.replace(/\//g
6
6
  const CSS_URL_PATTERN = /url\(\s*(['"]?)([^'")]+)\1\s*\)/g;
7
7
  const CODE_LANGUAGE_PATTERN = /\slanguage="([^"]+)"/g;
8
8
  const CONCURRENCY = 10;
9
+ const isLanguageIcon = (url) => url.startsWith(`${MINTLIFY_ICONS_CDN_URL}/devicon/`);
9
10
  export async function* walkFiles(dir) {
10
11
  for (const entry of await fse.readdir(dir, { withFileTypes: true })) {
11
12
  const entryPath = path.join(dir, entry.name);
@@ -107,7 +108,8 @@ export async function localizeAssets(exportDir, fetchAsset = fetchPublicAsset) {
107
108
  }
108
109
  const asset = await fetchAsset(url);
109
110
  if (!asset) {
110
- failed.push(url);
111
+ if (!isLanguageIcon(url))
112
+ failed.push(url);
111
113
  return;
112
114
  }
113
115
  await fse.ensureDir(path.dirname(outputPath));