summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-11-04 17:22:27 -0600
committerLuke Kanies <luke@madstop.com>2008-11-04 17:22:27 -0600
commita9dbb5de66c9a97d13f7e7ade47bb6c3b5fa2e66 (patch)
tree68cfc356eca467e18e1e4837dd7f575686693d11
parentbb6619a74866605a07869f9467273d6e2e389dab (diff)
downloadpuppet-a9dbb5de66c9a97d13f7e7ade47bb6c3b5fa2e66.tar.gz
puppet-a9dbb5de66c9a97d13f7e7ade47bb6c3b5fa2e66.tar.xz
puppet-a9dbb5de66c9a97d13f7e7ade47bb6c3b5fa2e66.zip
Deduplicating slashes in the fileserving code
Signed-off-by: Luke Kanies <luke@madstop.com>
-rw-r--r--lib/puppet/file_serving/base.rb4
-rwxr-xr-xspec/integration/indirector/direct_file_server.rb2
-rwxr-xr-xspec/unit/file_serving/base.rb5
3 files changed, 8 insertions, 3 deletions
diff --git a/lib/puppet/file_serving/base.rb b/lib/puppet/file_serving/base.rb
index c59a54786..2a0199dee 100644
--- a/lib/puppet/file_serving/base.rb
+++ b/lib/puppet/file_serving/base.rb
@@ -23,11 +23,11 @@ class Puppet::FileServing::Base
# Return the full path to our file. Fails if there's no path set.
def full_path
- if relative_path.nil? or relative_path == "" or relative_path == "."
+ (if relative_path.nil? or relative_path == "" or relative_path == "."
path
else
File.join(path, relative_path)
- end
+ end).gsub(%r{/+}, "/")
end
def initialize(path, options = {})
diff --git a/spec/integration/indirector/direct_file_server.rb b/spec/integration/indirector/direct_file_server.rb
index 417d661e8..c379bcbb7 100755
--- a/spec/integration/indirector/direct_file_server.rb
+++ b/spec/integration/indirector/direct_file_server.rb
@@ -64,7 +64,7 @@ describe Puppet::Indirector::DirectFileServer, " when interacting with FileServi
case instance.full_path
when /one/: instance.content.should == "one content"
when /two/: instance.content.should == "two content"
- when /\.$/:
+ when @path:
else
raise "No valid key for %s" % instance.path.inspect
end
diff --git a/spec/unit/file_serving/base.rb b/spec/unit/file_serving/base.rb
index 6a76d81e9..4eb62b038 100755
--- a/spec/unit/file_serving/base.rb
+++ b/spec/unit/file_serving/base.rb
@@ -90,6 +90,11 @@ describe Puppet::FileServing::Base do
@file.relative_path = "not/qualified"
@file.full_path.should == "/this/file/not/qualified"
end
+
+ it "should strip extra slashes" do
+ file = Puppet::FileServing::Base.new("//this//file")
+ file.full_path.should == "/this/file"
+ end
end
describe "when stat'ing files" do