Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Add default to replace urls

Jakub Novak939e3d64c018
diff --git a/apps/reverse-proxy/app/sitemap.ts b/apps/reverse-proxy/app/sitemap.ts
index 92d288551..e25533d12 100644
--- a/apps/reverse-proxy/app/sitemap.ts
+++ b/apps/reverse-proxy/app/sitemap.ts
@@ -78,16 +78,18 @@ async function getSitemap(
if (Array.isArray(data.urlset.url)) {
return data.urlset.url.map((line) => {
+ const url = new URL(line.loc)
return {
- url: replaceUrls(line.loc, line.loc),
+ url: replaceUrls(line.loc, url.pathname),
priority: line?.priority || site.priority,
changeFrequency: line?.changefreq || site.changeFrequency,
}
})
} else {
+ const url = new URL(data.urlset.url.loc)
return [
{
- url: replaceUrls(data.urlset.url.loc, data.urlset.url.loc),
+ url: replaceUrls(data.urlset.url.loc, url.pathname),
priority: data.urlset.url?.priority || site.priority,
changeFrequency: data.urlset.url?.changefreq || site.changeFrequency,
},
diff --git a/apps/reverse-proxy/utils/replaceUrls.ts b/apps/reverse-proxy/utils/replaceUrls.ts
index 4eeecfe8c..46320f677 100644
--- a/apps/reverse-proxy/utils/replaceUrls.ts
+++ b/apps/reverse-proxy/utils/replaceUrls.ts
@@ -1,4 +1,4 @@
-export function replaceUrls(text: string, urlPathName: string, prefix?: string, lastChar: string = ''): string {
+export function replaceUrls(text: string, urlPathName: string, prefix: string = '', lastChar: string = ''): string {
const pattern = lastChar ? `(?<url>${prefix}https://e2b-[^${lastChar}]*)/${lastChar}` : `(?<url>${prefix}https://e2b-.*)/`
return text.replaceAll(