blob: 13d7c04f142b1c3e3f013c2c03ee48c87a620ee9 [file] [log] [blame]
# Copyright 2019 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from urlparse import urlparse
from recipe_engine import recipe_api
class SSOApi(recipe_api.RecipeApi):
"""
API for SSO utility functions.
"""
def sso_to_https(self, remote):
"""
Transform a remote URL of SSO scheme to its associated https version.
If not SSO, do nothing.
Args:
remote (str): SSO or https remote URL.
Returns:
str: input as SSO URL.
"""
if not remote or not remote.startswith('sso://'):
return remote
url = urlparse(remote)
# Note that url.path contains a leading '/'.
return 'https://%s.googlesource.com%s' % (url.netloc, url.path)