From d44538ea47a05635728b10effd21a33aa887a005 Mon Sep 17 00:00:00 2001 From: awilliams1275 Date: Tue, 20 Aug 2024 18:33:21 -0400 Subject: [PATCH] devcommit35 --- _build/netlify.toml | 6 +++++- netlify.toml | 6 +++++- netlify/edge-functions/redirect_article.js | 9 ++++++--- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/_build/netlify.toml b/_build/netlify.toml index 5f35c6389..3be6e9500 100644 --- a/_build/netlify.toml +++ b/_build/netlify.toml @@ -17,7 +17,11 @@ path = "/py/" [[edge_functions]] function = "redirect_article" -path = "/*" +path = "/py/docs/*" + +[[edge_functions]] +function = "redirect_article" +path = "/py/api/*" [[redirects]] from = "http://shiny.rstudio.com/*" diff --git a/netlify.toml b/netlify.toml index 5f35c6389..3be6e9500 100644 --- a/netlify.toml +++ b/netlify.toml @@ -17,7 +17,11 @@ path = "/py/" [[edge_functions]] function = "redirect_article" -path = "/*" +path = "/py/docs/*" + +[[edge_functions]] +function = "redirect_article" +path = "/py/api/*" [[redirects]] from = "http://shiny.rstudio.com/*" diff --git a/netlify/edge-functions/redirect_article.js b/netlify/edge-functions/redirect_article.js index c1899f479..235434414 100644 --- a/netlify/edge-functions/redirect_article.js +++ b/netlify/edge-functions/redirect_article.js @@ -1,7 +1,10 @@ export default async (request, context) => { const url = new URL(request.url); - // Check if the URL path starts with /docs and ends with a trailing slash - if ( (url.pathname.startsWith('/py/docs') || url.pathname.startsWith('/py/api') ) && url.pathname.endsWith('/') ) { + const pattern = /\/(core|express|testing)(\/?)$/; + const result = pattern.test(url); + + // Check if the URL path is one of the index.html pages + if ( !result ) { // Remove the trailing slash and add .html extension const newPathname = url.pathname.slice(0, -1) + '.html'; const newUrl = `${url.origin}${newPathname}`; @@ -18,6 +21,6 @@ export default async (request, context) => { return context.next(); }; export const config = { - path: ['/*'], + path: ['/py/docs/*', "/py/api/*"], }; \ No newline at end of file