Skip to content

Commit

Permalink
Merge pull request #19 from azachwill/devcommit21
Browse files Browse the repository at this point in the history
hello
  • Loading branch information
awilliams1275 authored Aug 19, 2024
2 parents 97ed54e + 2df1372 commit a6ff902
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 30 deletions.
12 changes: 0 additions & 12 deletions _build/netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,6 @@ force = true

[redirects.headers]

[[redirects]]
from = "*/:splat/"
to = "/:splat.html"
status = 301
force = true

[redirects.query]

[redirects.conditions]

[redirects.headers]

[[redirects]]
from = "/articles/shinyapps-auth.html"
to = "https://docs.posit.co/shinyapps.io/authentication-and-user-management.html#authentication-and-user-management"
Expand Down
12 changes: 0 additions & 12 deletions netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,6 @@ force = true

[redirects.headers]

[[redirects]]
from = "*/:splat/"
to = "/:splat.html"
status = 301
force = true

[redirects.query]

[redirects.conditions]

[redirects.headers]

[[redirects]]
from = "/articles/shinyapps-auth.html"
to = "https://docs.posit.co/shinyapps.io/authentication-and-user-management.html#authentication-and-user-management"
Expand Down
31 changes: 25 additions & 6 deletions netlify/edge-functions/hello.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
export default async (request, context) => {
return new Response("Hello world",{
headers: {
"content-type": "text/html",
},
});
};
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.endsWith('/')) {
// Remove the trailing slash and add .html extension
const newPathname = url.pathname.slice(0, -1) + '.html';
const newUrl = `${url.origin}${newPathname}${url.search}`;

// Perform a 301 redirect
return new Response(null, {
status: 301,
headers: {
'Location': newUrl,
},
});
}

// If the URL does not match the criteria, proceed with the request as usual
return context.next();
};

export const config = {
path: '/py/docs/*',
};

0 comments on commit a6ff902

Please sign in to comment.