Skip to content

Commit f081177

Browse files
authored
Avoid duplication in r.bridgetown implementation (#939)
By choosing an appropriate argument to `on`, based on the base path, we don't need a separate if statement block and manual return. Additionally, the nil at the end is not needed, as `on` will either throw if it handles the request, or return nil if it does not.
1 parent 0ee33c7 commit f081177

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

bridgetown-core/lib/roda/plugins/bridgetown_server.rb

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -158,20 +158,11 @@ def bridgetown
158158
scope.initialize_bridgetown_context
159159
scope.initialize_bridgetown_root
160160

161-
# There are two different code paths depending on if there's a site `base_path` configured
162-
if Bridgetown::Current.preloaded_configuration.base_path == "/"
161+
base_path = Bridgetown::Current.preloaded_configuration.base_path.delete_prefix("/")
162+
on(base_path.empty? ? true : base_path) do
163163
ssg # static file server
164164
Bridgetown::Rack::Routes.load_all scope
165-
return
166165
end
167-
168-
# Support custom base_path configurations
169-
on(Bridgetown::Current.preloaded_configuration.base_path.delete_prefix("/")) do
170-
ssg # static file server
171-
Bridgetown::Rack::Routes.load_all scope
172-
end
173-
174-
nil
175166
end
176167
end
177168
end

0 commit comments

Comments
 (0)