From b14fe5d43502f46301da249a09f7d8f8e55a4db9 Mon Sep 17 00:00:00 2001 From: Chang-Hung Liang Date: Wed, 10 May 2017 12:31:25 +0800 Subject: [PATCH] Fix #116: --spec local path issue on Windows --- http_prompt/cli.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/http_prompt/cli.py b/http_prompt/cli.py index c4cc6f2..01e5a3e 100644 --- a/http_prompt/cli.py +++ b/http_prompt/cli.py @@ -2,6 +2,7 @@ import json import os +import re import sys import click @@ -16,8 +17,7 @@ from pygments.styles import get_style_by_name from pygments.util import ClassNotFound from six.moves.http_cookies import SimpleCookie -from six.moves.urllib.parse import urlparse -from six.moves.urllib.request import urlopen +from six.moves.urllib.request import urlopen, pathname2url from . import __version__ from . import config @@ -75,8 +75,8 @@ def response_returned(self, context, response): def normalize_url(ctx, param, value): if value: - if not urlparse(value).scheme: - value = 'file://' + os.path.abspath(value) + if not re.search(r'^\w+://', value): + value = 'file:' + pathname2url(os.path.abspath(value)) return value return None