diff --git a/lib/wpscan/wp_target.rb b/lib/wpscan/wp_target.rb index cfed24be..15d50054 100644 --- a/lib/wpscan/wp_target.rb +++ b/lib/wpscan/wp_target.rb @@ -33,7 +33,7 @@ class WpTarget attr_reader :uri, :verbose def initialize(target_url, options = {}) - @uri = URI.parse(add_http_protocol(target_url)) + @uri = URI.parse(add_trailing_slash(add_http_protocol(target_url))) @verbose = options[:verbose] @wp_content_dir = options[:wp_content_dir] @wp_plugins_dir = options[:wp_plugins_dir] diff --git a/spec/lib/wpscan/wp_target_spec.rb b/spec/lib/wpscan/wp_target_spec.rb index 582aff54..254aa58a 100644 --- a/spec/lib/wpscan/wp_target_spec.rb +++ b/spec/lib/wpscan/wp_target_spec.rb @@ -4,12 +4,12 @@ describe WpTarget do before :each do Browser.reset - browser_options = + @browser_options = { :config_file => SPEC_FIXTURES_CONF_DIR + '/browser/browser.conf.json', :cache_timeout => 0 } - @wp_target = WpTarget.new("http://example.localhost/", browser_options) + @wp_target = WpTarget.new("http://example.localhost/", @browser_options) end it_should_behave_like "WebSite" @@ -27,6 +27,14 @@ describe WpTarget do expect { WpTarget.new(nil) }.to raise_error expect { Wptarget.new('') }.to raise_error end + + it "should add the http protocol if missing" do + WpTarget.new("example.localhost/", @browser_options).url.should === "http://example.localhost/" + end + + it "should add the trailing slash to the url if missing" do + WpTarget.new("lamp/wordpress", @browser_options).url.should === "http://lamp/wordpress/" + end end describe "#url" do