Module: AppleCore::ActionView::Helpers::WebClientUrl
- Defined in:
- lib/apple_core/action_view/helpers/web_client_url.rb
Instance Method Summary collapse
-
#web_client_url(**options) ⇒ Object
rubocop:disable Metrics/AbcSize.
Instance Method Details
#web_client_url(**options) ⇒ Object
rubocop:disable Metrics/AbcSize
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/apple_core/action_view/helpers/web_client_url.rb', line 13 def web_client_url(**) route_name = .delete(:name) if defined?(::Chamber) = Chamber.env.web_client.slice('host', 'port', 'protocol') original_path = Chamber.env.web_client.urls[route_name] else = {} original_path = .delete(:path) end path = .dup.inject(original_path) do |memo, (key, value)| key_pattern = %r{/:#{key}(?=(/|\z))} if memo.match?(key_pattern) .delete(key) memo.gsub(key_pattern, "/#{value}") else memo end end = .merge() anchor = .delete('anchor') arguments = [ .delete('protocol'), .delete('authentication'), .delete('host'), .delete('port') || 443, nil, path, nil, .to_query, anchor, ] URI::HTTPS.new(*arguments).to_s end |