From 9d96e767a1baf3b7737440eae0f1d2c5d433f798 Mon Sep 17 00:00:00 2001 From: preetwinder Date: Thu, 24 Sep 2015 17:31:30 +0000 Subject: [PATCH] Minor changes to add_http_if_no_scheme --- scrapy/utils/url.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scrapy/utils/url.py b/scrapy/utils/url.py index c0934ddcf..398407a64 100644 --- a/scrapy/utils/url.py +++ b/scrapy/utils/url.py @@ -111,11 +111,13 @@ def escape_ajax(url): return url return add_or_replace_parameter(defrag, '_escaped_fragment_', frag[1:]) + def add_http_if_no_scheme(url): - """Adds http as the default scheme if it is missing from the url""" - parser = parse_url(url) + """Add http as the default scheme if it is missing from the url.""" if url.startswith('//'): url = 'http:' + url - elif not parser.scheme or not parser.netloc: + return url + parser = parse_url(url) + if not parser.scheme or not parser.netloc: url = 'http://' + url return url