gatsby-plugin-client-side-redirect
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -13,3 +13,3 @@ module.exports = function getMetaRedirect(toPath) { | ||
if(hasTrailingSlash) { | ||
if (hasTrailingSlash && url.length > 1) { | ||
url = url.slice(0, -1); | ||
@@ -16,0 +16,0 @@ } |
@@ -12,7 +12,15 @@ const path = require('path'); | ||
const FILE_PATH = path.join( | ||
folder, | ||
fromPath.replace(pathPrefix, ''), | ||
'index.html' | ||
); | ||
let FILE_PATH | ||
if (fromPath.endsWith(".html")) { | ||
// Allow redirects from file | ||
FILE_PATH = path.join(folder, fromPath.replace(pathPrefix, '')); | ||
} else { | ||
// If it's not a .html file, then use the xyz/index.html pattern | ||
// to support an exact link | ||
FILE_PATH = path.join( | ||
folder, | ||
fromPath.replace(pathPrefix, ''), | ||
'index.html' | ||
); | ||
} | ||
@@ -19,0 +27,0 @@ const fileExists = await exists(FILE_PATH); |
{ | ||
"name": "gatsby-plugin-client-side-redirect", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"repository": "git@github.com:dhakerShiv/gatsby-plugin-client-side-redirect.git", | ||
@@ -5,0 +5,0 @@ "author": "Shivnarayan Dhaker <shivnarayandhakar@gmail.com>", |
@@ -46,3 +46,3 @@ # gatsby-plugin-client-side-redirect | ||
You can use it using an node api provided by gatsby, for an example | ||
You can use it using the node api provided by gatsby, for an example | ||
Let's take `createPages` | ||
@@ -52,3 +52,3 @@ | ||
``` | ||
```js | ||
exports.createPages = ({ graphql, actions }) => { | ||
@@ -63,3 +63,3 @@ const {createRedirect} = actions //actions is collection of many actions - https://www.gatsbyjs.org/docs/actions | ||
``` | ||
```js | ||
exports.createPages = async ({ graphql, actions }) => { | ||
@@ -66,0 +66,0 @@ const {createRedirect} = actions |
5783
9
61