Sylvestre HF Staff commited on
Commit
7c842da
·
1 Parent(s): 7a5d54d

fix: iframe protocol binding

Browse files
Files changed (1) hide show
  1. app.ts +6 -14
app.ts CHANGED
@@ -3,25 +3,17 @@ import express from "express";
3
 
4
  const app = express();
5
 
6
- app.use("/", (req, res, next) => {
7
- const originalSend = res.send.bind(res);
8
- res.send = (x) =>
9
- originalSend(
10
- x.replace(
11
- "</html>",
12
- `<script>addEventListener(
13
- 'hashchange',
14
- event => {
15
- parent.postMessage({hash: new URL(event.newURL).hash.slice(1)}, '*');
16
- }
17
- )</script></html>`
18
- )
19
- );
20
  return apiReference({
21
  url: "https://huggingface.co/.well-known/openapi.json",
22
  title: "Hub API Endpoints",
 
23
  hideClientButton: true,
24
  defaultOpenAllTags: true,
 
 
 
 
25
  })(req, res);
26
  });
27
 
 
3
 
4
  const app = express();
5
 
6
+ app.use("/", (req, res, next) => {
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  return apiReference({
8
  url: "https://huggingface.co/.well-known/openapi.json",
9
  title: "Hub API Endpoints",
10
+ pageTitle: "Hub API Endpoints",
11
  hideClientButton: true,
12
  defaultOpenAllTags: true,
13
+ onSidebarClick: (href) => {
14
+ const url = new URL(href);
15
+ parent.postMessage({ hash: url.hash.slice(1) }, '*');
16
+ },
17
  })(req, res);
18
  });
19