https://github.com/jekyll/jekyll
Raw File
Tip revision: 031ff12eaf99db26eeb29c85b827e7ef76cf40e6 authored by Parker Moore on 27 October 2015, 03:23:00 UTC
Release :gem: 3.0.0
Tip revision: 031ff12
test_path_sanitization.rb
require 'helper'

class TestPathSanitization < JekyllUnitTest
  context "on Windows with absolute source" do
    setup do
      @source = "C:/Users/xmr/Desktop/mpc-hc.org"
      @dest   = "./_site/"
      allow(Dir).to receive(:pwd).and_return("C:/Users/xmr/Desktop/mpc-hc.org")
    end
    should "strip drive name from path" do
      assert_equal "C:/Users/xmr/Desktop/mpc-hc.org/_site", Jekyll.sanitized_path(@source, @dest)
    end

    should "strip just the initial drive name" do
      assert_equal "/tmp/foobar/jail/..c:/..c:/..c:/etc/passwd", Jekyll.sanitized_path("/tmp/foobar/jail", "..c:/..c:/..c:/etc/passwd")
    end
  end
end
back to top