about summary refs log tree commit
path: root/lib/metropolis.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-12-05 15:34:56 -0800
committerEric Wong <normalperson@yhbt.net>2010-12-05 15:41:37 -0800
commit74ca34be2d54809822447ff185d88d83fcd566ae (patch)
tree6d062e8b82b72996a5e53840f7e3517ddaaaae66 /lib/metropolis.rb
parenta84908349094bd8835d3261cd8b11dde863178fd (diff)
downloadmetropolis-74ca34be2d54809822447ff185d88d83fcd566ae.tar.gz
:path_pattern is independent of the URI
It can be confusing with printf-style patterns in URIs,
so just force path_pattern-users to specify "/" as their
path.
Diffstat (limited to 'lib/metropolis.rb')
-rw-r--r--lib/metropolis.rb7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/metropolis.rb b/lib/metropolis.rb
index e9810d7..425ce1c 100644
--- a/lib/metropolis.rb
+++ b/lib/metropolis.rb
@@ -14,18 +14,19 @@ module Metropolis
     opts = opts.dup
     rv = Object.new
     uri = opts[:uri] = URI.parse(opts[:uri])
+    if uri.path != '/' && opts[:path_pattern]
+      raise ArgumentError, ":path_pattern may only be used if path is '/'"
+    end
     case uri.scheme
     when 'hash'
       opts[:path] = uri.path if uri.path != '/'
       rv.extend Metropolis::Hash
     when 'tdb'
-      opts[:path_pattern] = uri.path
       opts[:query] = Rack::Utils.parse_query(uri.query) if uri.query
       rv.extend Metropolis::TDB
     when 'tc'
-      opts[:path_pattern] = uri.path
       opts[:query] = Rack::Utils.parse_query(uri.query) if uri.query
-      case ext = File.extname(uri.path)
+      case ext = File.extname(opts[:path_pattern] || uri.path)
       when '.tch'
         rv.extend Metropolis::TC::HDB
       else