Browse files

case-insensitive URL matching

  • Loading branch information...
1 parent 4174ac0 commit 5387cea904c971bc0163706f659cbf7c1ba5925f @jlong jlong committed Mar 15, 2011
Showing with 9 additions and 1 deletion.
  1. +1 −1 lib/serve/file_resolver.rb
  2. +8 −0 spec/file_resolver_spec.rb
View
2 lib/serve/file_resolver.rb
@@ -32,7 +32,7 @@ def resolve_with_extension(root, path)
if File.file?(full_path)
path
else
- result = Dir.glob(full_path + ".*").first
+ result = Dir.glob(full_path + ".*", File::FNM_CASEFOLD).first
result.sub(/^#{root}/, '').sub(/^\//, '') if result && File.file?(result)
end
end
View
8 spec/file_resolver_spec.rb
@@ -46,6 +46,14 @@
FileUtils.rm(@root + full_path)
end
+ it 'should resolve files without case sensitivity' do
+ resolve('HELLO').should == 'hello.html'
+ end
+
+ it 'should resolve directories without case sensitivity' do
+ resolve('DIRECTORY').should == 'directory/index.html'
+ end
+
def resolve(name)
Serve::FileResolver.instance.resolve(@root, name)
end

0 comments on commit 5387cea

Please sign in to comment.