Skip to content

Commit

Permalink
Feat(p-gslide): Handle different regions on link
Browse files Browse the repository at this point in the history
  • Loading branch information
Vija02 committed Nov 13, 2024
1 parent df5b443 commit ad73948
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions plugins/google-slides/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,14 @@ export const init = (
);
});

// TODO: Handle different regions
// Maybe we want to cache it too?
// DEBT: Maybe we can cache this
const apiProxy = createProxyMiddleware({
target: "https://lh7-rt.googleusercontent.com",
pathRewrite: (path) => {
return "/" + path.split("/").slice(2).join("/");
},
router: (req) => {
return `https://${req.url?.split("/")[1]}.googleusercontent.com`;
},
on: {
proxyReq: (proxyReq) => {
proxyReq.removeHeader("Referer");
Expand Down Expand Up @@ -288,12 +292,12 @@ function processHtml(html: string) {
"/plugin/google-slides/staticScripts/static/presentation/client/",
)
.replace(
/https:\/\/lh7-rt\.googleusercontent\.com/g,
"/plugin/google-slides/staticProxy",
/https:\/\/([^.]+?)\.googleusercontent\.com/g,
"/plugin/google-slides/staticProxy/$1",
)
.replace(
/https:\\\/\\\/lh7-rt\.googleusercontent\.com/g,
"/plugin/google-slides/staticProxy",
/https:\\\/\\\/([^.]+?)\.googleusercontent\.com/g,
"/plugin/google-slides/staticProxy/$1",
);
}

Expand Down

0 comments on commit ad73948

Please sign in to comment.