# HG changeset patch # User Ludovic Chabant # Date 1465540335 25200 # Node ID 7dbddfed8129b194e4c103afcb764c58dc316bea # Parent 925f25ed9a54681d7298973ef414238e3a9d1e83 config: Fix how we parse the root URL to allow for absolute and user URLs. diff -r 925f25ed9a54 -r 7dbddfed8129 piecrust/appconfig.py --- a/piecrust/appconfig.py Thu Jun 09 22:35:18 2016 -0700 +++ b/piecrust/appconfig.py Thu Jun 09 23:32:15 2016 -0700 @@ -548,12 +548,18 @@ return v -# Make sure the site root starts and ends with a slash. +# Make sure the site root ends with a slash. def _validate_site_root(v, values, cache): - if not v.startswith('/'): - raise ConfigurationError("The `site/root` setting must start " - "with a slash.") - root_url = urllib.parse.quote(v.rstrip('/') + '/') + url_bits = urllib.parse.urlparse(v) + if url_bits.params or url_bits.query or url_bits.fragment: + raise ConfigurationError("Root URL is invalid: %s" % v) + + path = url_bits.path.rstrip('/') + '/' + if '%' not in path: + path = urllib.parse.quote(path) + + root_url = urllib.parse.urlunparse(( + url_bits.scheme, url_bits.netloc, path, '', '', '')) return root_url