Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #814 from B77Mills/nativeXTrailingSlash
Browse files Browse the repository at this point in the history
Redirect nativeX story paths to non-trailing /
  • Loading branch information
solocommand authored Oct 19, 2023
2 parents da860c0 + 3524dc5 commit a96bec0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/marko-web-native-x/middleware/with-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ module.exports = ({
template,
queryFragment = defaultFragment,
} = {}) => asyncRoute(async (req, res) => {
const { path, url } = req;
if (path.substr(-1) === '/' && path.length > 1) {
const query = url.slice(path.length);
const safe = path.slice(0, -1).replace(/\/+/g, '/');
res.redirect(301, `${safe}${query}`);
return;
}

const { id } = req.params;
const preview = Boolean(req.query.preview);
const result = await config.client.query({
Expand Down

0 comments on commit a96bec0

Please sign in to comment.