From 2b52b0fd32a4348591ed0c570319897899b579ce Mon Sep 17 00:00:00 2001 From: Brandon Keepers Date: Fri, 1 Mar 2024 09:00:21 -0500 Subject: [PATCH] Fix url_for when app is mapped to namespace --- lib/flipper/ui/action.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/flipper/ui/action.rb b/lib/flipper/ui/action.rb index 61557d8b..0ff4053e 100644 --- a/lib/flipper/ui/action.rb +++ b/lib/flipper/ui/action.rb @@ -219,8 +219,14 @@ def script_name request.env['SCRIPT_NAME'] end + # Internal: Generate urls relative to the app's script name. + # + # url_for("feature") # => "http://localhost:9292/flipper/feature" + # url_for("/thing") # => "http://localhost:9292/thing" + # url_for("https://example.com") # => "https://example.com" + # def url_for(*parts) - URI.join(request.base_url, script_name, *parts).to_s + URI.join(request.base_url, script_name + '/', *parts).to_s end # Private