Class: Federails::Utils::Host
- Inherits:
-
Object
- Object
- Federails::Utils::Host
- Defined in:
- lib/federails/utils/host.rb
Constant Summary collapse
- COMMON_PORTS =
[80, 443].freeze
Class Method Summary collapse
-
.local_route(url) ⇒ ActionDispatch::Routing::RouteSet?
Gets the route on the current instance, or nil.
-
.local_url?(url) ⇒ true, false
Checks if the given URL points somewhere on current instance.
-
.localhost ⇒ String
Host and port of the current instance.
Class Method Details
.local_route(url) ⇒ ActionDispatch::Routing::RouteSet?
Gets the route on the current instance, or nil
32 33 34 35 36 37 38 |
# File 'lib/federails/utils/host.rb', line 32 def local_route(url) return nil unless local_url? url Rails.application.routes.recognize_path(url) rescue ActionController::RoutingError nil end |
.local_url?(url) ⇒ true, false
Checks if the given URL points somewhere on current instance
20 21 22 23 24 |
# File 'lib/federails/utils/host.rb', line 20 def local_url?(url) uri = URI.parse url host = host_and_port uri.host, uri.port localhost == host end |