summary refs log tree commit
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2019-06-27 19:17:32 -0400
committerGitHub <noreply@github.com>2019-06-27 19:17:32 -0400
commit2d41895fdcfb3c93c23afe702691ad8a9becf62c (patch)
tree52a635f6129ef36e30faaea1ff042dedcee4fe4b
parent70c838f7204f9bb08992d2b68b1d52b80c97b016 (diff)
parentdd396f693c8bc29332864f38b8c5fee2c6de5aa0 (diff)
downloadrack-2d41895fdcfb3c93c23afe702691ad8a9becf62c.tar.gz
Merge pull request #1373 from olleolleolle/host-using-index-instead-of-regex
Avoid regex in Request#host
-rw-r--r--lib/rack/request.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/rack/request.rb b/lib/rack/request.rb
index f999cd4a..951fe8cb 100644
--- a/lib/rack/request.rb
+++ b/lib/rack/request.rb
@@ -243,7 +243,12 @@ module Rack
 
       def host
         # Remove port number.
-        host_with_port.to_s.sub(/:\d+\z/, '')
+        h = host_with_port
+        if colon_index = h.index(":")
+          h[0, colon_index]
+        else
+          h
+        end
       end
 
       def port