Skip to content

Commit

Permalink
style: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Jun 15, 2023
1 parent 2dfd31d commit 6737ff8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,11 @@ export default defineNuxtModule<ModuleOptions>({
nuxt.hook('nitro:init', nitro => {
publicFolder = nitro.options.output.publicDir
})

nuxt.hook('close', async () => {
const indexFile = join(publicFolder, 'index.html')
const fallbackFile = join(publicFolder, '200.html')

if (!existsSync(indexFile) && existsSync(fallbackFile)) {
await fsp.copyFile(fallbackFile, indexFile)
}
Expand Down
11 changes: 7 additions & 4 deletions src/runtime/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,15 @@ export default defineNuxtPlugin(async nuxtApp => {
const middleware =
typeof entry === 'string'
? nuxtApp._middleware.named[entry] ||
(await namedMiddleware[entry]?.().then((r: any) => r.default || r))
(await namedMiddleware[entry]?.().then((r: any) => r.default || r))
: entry

if (!middleware) {
if (process.dev) {
throw new Error(
`Unknown route middleware: '${entry}'. Valid middleware: ${Object.keys(namedMiddleware)
`Unknown route middleware: '${entry}'. Valid middleware: ${Object.keys(
namedMiddleware
)
.map(mw => `'${mw}'`)
.join(', ')}.`
)
Expand Down Expand Up @@ -174,7 +176,8 @@ export default defineNuxtPlugin(async nuxtApp => {
if (!isEqual(currentURL, initialURL, { trailingSlash: true })) {
const event = await callWithNuxt(nuxtApp, useRequestEvent)
const options = {
redirectCode: event.node.res.statusCode !== 200 ? event.node.res.statusCode || 302 : 302,
redirectCode:
event.node.res.statusCode !== 200 ? event.node.res.statusCode || 302 : 302,
}
await callWithNuxt(nuxtApp, navigateTo, [currentURL, options])
}
Expand All @@ -186,7 +189,7 @@ export default defineNuxtPlugin(async nuxtApp => {
await router.replace({
...router.resolve(initialURL),
name: undefined, // #4920, #4982
force: true
force: true,
})
}
} catch (error: any) {
Expand Down

0 comments on commit 6737ff8

Please sign in to comment.