extract_path_info(environ_or_baseurl, path_or_url, charset='utf-8', errors='replace', collapse_http_schemes=True)¶
Extracts the path info from the given URL (or WSGI environment) and path. The path info returned is a unicode string, not a bytestring suitable for a WSGI environment. The URLs might also be IRIs.
If the path info could not be determined, None is returned.
>>> extract_path_info('http://example.com/app', '/app/hello') u'/hello' >>> extract_path_info('http://example.com/app', ... 'https://example.com/app/hello') u'/hello' >>> extract_path_info('http://example.com/app', ... 'https://example.com/app/hello', ... collapse_http_schemes=False) is None True
Instead of providing a base URL you can also pass a WSGI environment.
New in version 0.6.
- environ_or_baseurl – a WSGI environment dict, a base URL or base IRI. This is the root of the application.
- path_or_url – an absolute path from the server root, a relative path (in which case it’s the path info) or a full URL. Also accepts IRIs and unicode parameters.
- charset – the charset for byte data in URLs
- errors – the error handling on decode
- collapse_http_schemes – if set to False the algorithm does not assume that http and https on the same server point to the same resource.