From 74ca34be2d54809822447ff185d88d83fcd566ae Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 5 Dec 2010 15:34:56 -0800 Subject: :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. --- lib/metropolis.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lib/metropolis.rb') 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 -- cgit v1.2.3-24-ge0c7