Skip to content

Commit

Permalink
fix: error on named routes
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobrosenberg committed Nov 21, 2024
1 parent 82b888a commit 1a5e01b
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions lib/runtime/Router/Router.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,6 @@ const stripNullFields = obj =>

const defaultPlugins = [reset(), scroller(), stripTrailingIndex()]

const getName = name => {
while (appInstance.routers.find(r => r.name == name)) {
throw new Error(`Router with name "${name}" already exists`)
}
return name
}

/**
* @implements { Readable<Router> }
*/
Expand Down Expand Up @@ -151,9 +144,7 @@ export class Router {
matchingRouter.init(input)
return matchingRouter
}
throw new Error(`Router with name "${name}" already exists`)
// bump the number suffixed to the name, if a number isn't suffixed, add 1
input.name = getName(input.name || '')
throw new Error(`Router with name "${input.name}" already exists`)
}

const { subscribe, set } = writable(this)
Expand Down

0 comments on commit 1a5e01b

Please sign in to comment.