Skip to content

Commit

Permalink
fix: static content for routePrefix with subpath (#165) (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
miraries authored Aug 14, 2024
1 parent f496b19 commit 4540c0c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/index-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

function indexHtml (opts) {
return (hasTrailingSlash) => {
const prefix = hasTrailingSlash ? `.${opts.staticPrefix}` : `.${opts.prefix}${opts.staticPrefix}`
const prefix = hasTrailingSlash ? `.${opts.staticPrefix}` : `${opts.prefix}${opts.staticPrefix}`
return `<!-- HTML for static distribution bundle build -->
<!DOCTYPE html>
<html lang="en">
Expand Down
16 changes: 8 additions & 8 deletions test/route.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -548,10 +548,10 @@ test('/documentation should display index html with correct asset urls', async (
url: '/documentation'
})

t.equal(res.payload.includes('href="./documentation/static/index.css"'), true)
t.equal(res.payload.includes('src="./documentation/static/theme/theme-js.js"'), true)
t.equal(res.payload.includes('href="./documentation/index.css"'), false)
t.equal(res.payload.includes('src="./documentation/theme/theme-js.js"'), false)
t.equal(res.payload.includes('href="/documentation/static/index.css"'), true)
t.equal(res.payload.includes('src="/documentation/static/theme/theme-js.js"'), true)
t.equal(res.payload.includes('href="/documentation/index.css"'), false)
t.equal(res.payload.includes('src="/documentation/theme/theme-js.js"'), false)
})

test('/documentation/ should display index html with correct asset urls', async (t) => {
Expand Down Expand Up @@ -582,10 +582,10 @@ test('/docs should display index html with correct asset urls when documentation
url: '/docs'
})

t.equal(res.payload.includes('href="./docs/static/index.css"'), true)
t.equal(res.payload.includes('src="./docs/static/theme/theme-js.js"'), true)
t.equal(res.payload.includes('href="./docs/index.css"'), false)
t.equal(res.payload.includes('src="./docs/theme/theme-js.js"'), false)
t.equal(res.payload.includes('href="/docs/static/index.css"'), true)
t.equal(res.payload.includes('src="/docs/static/theme/theme-js.js"'), true)
t.equal(res.payload.includes('href="/docs/index.css"'), false)
t.equal(res.payload.includes('src="/docs/theme/theme-js.js"'), false)
})

test('/docs/ should display index html with correct asset urls when documentation prefix is set', async (t) => {
Expand Down

0 comments on commit 4540c0c

Please sign in to comment.