lib/galago/router/path.rb in galago-router-0.1.0 vs lib/galago/router/path.rb in galago-router-0.1.1
- old
+ new
@@ -1,8 +1,18 @@
module Galago
class Router
class Path
+ REPEATED_SLASH = /\/{1,}/
+ TRAILING_SLASH = /\/$/
+
+ def self.join(*paths)
+ path = "/#{paths.join('/')}"
+ path = path.gsub(REPEATED_SLASH, '/')
+ path = path.gsub(TRAILING_SLASH, '')
+ path
+ end
+
def initialize(path)
@path = path.to_s
end
def recognizes?(request_path)