Fix unquote compatibility

This commit is contained in:
sloria
2014-07-10 22:16:20 -04:00
parent 9334d6b05c
commit dac0d4b748
2 changed files with 6 additions and 4 deletions

View File

@@ -6,9 +6,11 @@ PY2 = int(sys.version[0]) == 2
if PY2:
from urlparse import urljoin, urlparse, urlunparse
import urllib
urljoin = urljoin
urlparse = urlparse
urlunparse = urlunparse
urlunquote = urllib.unquote
import SimpleHTTPServer as httpserver
httpserver = httpserver
@@ -21,10 +23,11 @@ if PY2:
unicode = unicode
basestring = basestring
else: # PY3
from urllib.parse import urljoin, urlparse, urlunparse
from urllib.parse import urljoin, urlparse, urlunparse, unquote
urljoin = urljoin
urlparse = urlparse
urlunparse = urlunparse
urlunquote = unquote
import http.server as httpserver
httpserver = httpserver

View File

@@ -3,14 +3,13 @@ from __future__ import print_function
from watchdog import events, observers
from mkdocs.build import build
from mkdocs.compat import httpserver, socketserver
from mkdocs.compat import httpserver, socketserver, urlunquote
from mkdocs.config import load_config
import os
import posixpath
import shutil
import sys
import tempfile
import urllib
class BuildEventHandler(events.FileSystemEventHandler):
@@ -49,7 +48,7 @@ class FixedDirectoryHandler(httpserver.SimpleHTTPRequestHandler):
# abandon query parameters
path = path.split('?', 1)[0]
path = path.split('#', 1)[0]
path = posixpath.normpath(urllib.unquote(path))
path = posixpath.normpath(urlunquote(path))
words = path.split('/')
words = filter(None, words)
path = self.base_dir