Skip to content

Commit

Permalink
fix duplicate routes issue in Page()
Browse files Browse the repository at this point in the history
  • Loading branch information
hhaensel committed Nov 27, 2024
1 parent 4b767ca commit 9322e93
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Pages.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,19 @@ function Page( route::Union{Route,String};
if isempty(_pages)
push!(_pages, page)
else
for i in eachindex(_pages)
new_page = true
replaced = false
for i in reverse(eachindex(_pages))
if _pages[i].route.path == route.path && _pages[i].route.method == route.method
# if already replaced then delete the duplicate
replaced && deleteat!(_pages, i)
Router.delete!(Router.routename(_pages[i].route))
_pages[i] = page
else
push!(_pages, page)
new_page = false
replaced = true
end
end
new_page && push!(_pages, page)
end

Router.route(route)
Expand Down

0 comments on commit 9322e93

Please sign in to comment.