Skip to content
Browse files

urls only need to end with a trailing slash if there is no path compo…

…nent. close #30
  • Loading branch information...
1 parent 2d1e236 commit 216f3eaa19207217f255359742b3d03263de223f @cosmin cosmin committed Jan 4, 2013
Showing with 6 additions and 4 deletions.
  1. +6 −4 beeswithmachineguns/main.py
View
10 beeswithmachineguns/main.py
@@ -25,12 +25,10 @@
"""
import bees
-import re
+from urlparse import urlparse
from optparse import OptionParser, OptionGroup
-NO_TRAILING_SLASH_REGEX = re.compile(r'^.*?\.\w+$')
-
def parse_options():
"""
Handle the command line arguments for spinning up bees
@@ -112,7 +110,11 @@ def parse_options():
if not options.url:
parser.error('To run an attack you need to specify a url with -u')
- if NO_TRAILING_SLASH_REGEX.match(options.url):
+ parsed = urlparse(options.url)
+ if not parsed.scheme:
+ parsed = urlparse("http://" + options.url)
+
+ if not parsed.path:
parser.error('It appears your URL lacks a trailing slash, this will disorient the bees. Please try again with a trailing slash.')
bees.attack(options.url, options.number, options.concurrent)

0 comments on commit 216f3ea

Please sign in to comment.
Something went wrong with that request. Please try again.