@mintlify/previewing 4.0.1553 → 4.0.1554

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.
@@ -46,6 +46,8 @@ const decodePathname = (pathname) => {
46
46
  }
47
47
  };
48
48
  const MARKDOWN_PREFIX = '_markdown/';
49
+ const MARKDOWN_SUFFIX = /\.md$/;
50
+ const RSS_SUFFIX = /\/?rss\.xml$/;
49
51
  const OG_PREVIEW_PREFIX = '_mintlify/og/';
50
52
  const OG_PREVIEW_EXTENSION = '.png';
51
53
  const pageSlugFromOgPreview = (slug) => {
@@ -58,6 +60,7 @@ const slugFromPathname = (pathname) => {
58
60
  if (slug.startsWith(MARKDOWN_PREFIX)) {
59
61
  slug = slug.slice(MARKDOWN_PREFIX.length);
60
62
  }
63
+ slug = slug.replace(MARKDOWN_SUFFIX, '').replace(RSS_SUFFIX, '');
61
64
  slug = pageSlugFromOgPreview(slug) ?? slug;
62
65
  if (slug === '') {
63
66
  return 'index';
@@ -93,10 +93,10 @@ export const run = async (argv) => {
93
93
  res.status(502).json({ error: 'search proxy failed' });
94
94
  }
95
95
  });
96
- app.post('/_mintlify/api-public/assistant/:subdomain/message', express.json({ limit: ASSISTANT_MESSAGE_JSON_LIMIT }), async (req, res) => {
96
+ const assistantProxy = (message) => async (req, res) => {
97
97
  const targetSubdomain = subdomain ?? req.params.subdomain;
98
98
  try {
99
- const upstream = await fetch(`${apiUrl}/api/cli/${targetSubdomain}/assistant/message`, {
99
+ const upstream = await fetch(`${apiUrl}/api/cli/${targetSubdomain}/assistant/${message}`, {
100
100
  method: 'POST',
101
101
  headers: {
102
102
  'Content-Type': 'application/json',
@@ -131,7 +131,10 @@ export const run = async (argv) => {
131
131
  res.destroy();
132
132
  }
133
133
  }
134
- });
134
+ };
135
+ for (const message of ['message', 'v2/message']) {
136
+ app.post(`/_mintlify/api-public/assistant/:subdomain/${message}`, express.json({ limit: ASSISTANT_MESSAGE_JSON_LIMIT }), assistantProxy(message));
137
+ }
135
138
  app.all('*', (req, res) => requestHandler(req, res));
136
139
  const onChange = () => {
137
140
  io.emit('reload');