blob: cdef8d042b19478ae8675b87cd327a9784474189 [file] [log] [blame]
# Copyright 2014 the Melange authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""HTTP-related but otherwise miscellaneous utilities."""
import urlparse
def schemeRelativeURL(absolute_url):
"""Constructs a scheme-relative URL from an absolute URL.
Args:
absolute_url: Any absolute URL.
Returns:
A scheme-relative URL identifying the same resource as the given
absolute URL.
"""
scheme = urlparse.urlparse(absolute_url)[0]
return absolute_url[len(scheme) + 1:]