Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/lib/helpers/convertToBasePathRedirects.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// NOTE: /withoutProps/redirects.js has some of its own contained basePath logic

const getBasePathDefaultRedirects = ({ basePath, nextRedirects }) => {
if (basePath === '') return []
if (!basePath) return []
// In a basePath-configured site, all _next assets are fetched with the prepended basePath
return [
{
Expand All @@ -16,7 +16,7 @@ const getBasePathDefaultRedirects = ({ basePath, nextRedirects }) => {
}

const convertToBasePathRedirects = ({ basePath, nextRedirects }) => {
if (basePath === '') return nextRedirects
if (!basePath) return nextRedirects
const basePathRedirects = getBasePathDefaultRedirects({ basePath, nextRedirects })
nextRedirects.forEach((r) => {
if (r.route === '/') {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/helpers/formatRedirectTarget.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const { DYNAMIC_PARAMETER_REGEX } = require('../constants/regex')

const formatRedirectTarget = ({ basePath, target }) =>
basePath !== '' && target.includes(basePath)
basePath && basePath !== '' && target.includes(basePath)
? target.replace(DYNAMIC_PARAMETER_REGEX, '/:$1').replace('[', '').replace(']', '').replace('...', '')
: target

Expand Down
2 changes: 1 addition & 1 deletion src/lib/pages/withoutProps/redirects.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const getRedirects = async () => {

// For sites that use basePath, manually add necessary redirects here specific
// only to this page type (which excludes static route redirects by default)
if (basePath !== '') {
if (basePath && basePath !== '') {
redirects.push({
route: `${basePath}${route}`,
target: route,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/steps/setupRedirects.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const setupRedirects = async (publishPath) => {
redirects.push('# Next-on-Netlify Redirects')

const { basePath } = await getNextConfig()
if (basePath !== '') {
if (basePath && basePath !== '') {
nextRedirects = convertToBasePathRedirects({ basePath, nextRedirects })
}

Expand Down