Skip to content

Commit

Permalink
fix(generator): respect options.router.trailingSlash for crawler (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
manniL committed May 28, 2020
1 parent 2e711c1 commit c144716
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/generator/src/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,15 @@ export default class Generator {

// If crawler activated and called from generateRoutes()
if (this.options.generate.crawler && this.options.render.ssr) {
const possibleTrailingSlash = this.options.router.trailingSlash ? '/' : ''
parse(html).querySelectorAll('a').map((el) => {
const href = (el.getAttribute('href') || '').replace(/\/+$/, '').split('?')[0].split('#')[0].trim()
const sanitizedHref = (el.getAttribute('href') || '')
.replace(/\/+$/, '')
.split('?')[0]
.split('#')[0]
.trim()

const href = sanitizedHref + possibleTrailingSlash

if (href.startsWith('/') && !path.extname(href) && this.shouldGenerateRoute(href) && !this.generatedRoutes.has(href)) {
this.generatedRoutes.add(href) // add the route to the tracked list
Expand Down

0 comments on commit c144716

Please sign in to comment.