Skip to content

Commit 792e183

Browse files
committed
Revert root_prefix and to_regexp
1 parent 4c86f10 commit 792e183

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

lib/grape/path.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,22 @@ def self.prepare(raw_path, namespace, settings)
77
Path.new(raw_path, namespace, settings)
88
end
99

10-
attr_reader :raw_path, :namespace, :settings, :root_prefix
10+
attr_reader :raw_path, :namespace, :settings
1111

1212
def initialize(raw_path, namespace, settings)
1313
@raw_path = raw_path
1414
@namespace = namespace
1515
@settings = settings
16-
@root_prefix = settings[:root_prefix]&.to_s&.split('/')
1716
end
1817

1918
def mount_path
2019
settings[:mount_path]
2120
end
2221

22+
def root_prefix
23+
split_setting(:root_prefix)
24+
end
25+
2326
def uses_specific_format?
2427
if settings.key?(:format) && settings.key?(:content_types)
2528
settings[:format] && Array(settings[:content_types]).size == 1

lib/grape/router.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def compile!
3030
routes = map[method]
3131
optimized_map = routes.map.with_index do |route, index|
3232
route.index = index
33-
Regexp.new("(?<_#{index}>#{route.to_regexp})")
33+
Regexp.new("(?<_#{index}>#{route.pattern.to_regexp})")
3434
end
3535
@optimized_map[method] = Regexp.union(optimized_map)
3636
end

0 commit comments

Comments
 (0)