| Index: client/internal/lhttp/utils.go
|
| diff --git a/client/internal/lhttp/utils.go b/client/internal/lhttp/utils.go
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..222d281d9bbbae94af66d64b05cf11a004f707de
|
| --- /dev/null
|
| +++ b/client/internal/lhttp/utils.go
|
| @@ -0,0 +1,29 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +package lhttp
|
| +
|
| +import (
|
| + "errors"
|
| + "net/url"
|
| + "strings"
|
| +)
|
| +
|
| +// URLToHTTPS ensures the url is https://.
|
| +func URLToHTTPS(s string) (string, error) {
|
| + u, err := url.Parse(s)
|
| + if err != nil {
|
| + return "", err
|
| + }
|
| + if u.Scheme != "" && u.Scheme != "https" {
|
| + return "", errors.New("Only https:// scheme is accepted. It can be omitted.")
|
| + }
|
| + if !strings.HasPrefix(s, "https://") {
|
| + s = "https://" + s
|
| + }
|
| + if _, err = url.Parse(s); err != nil {
|
| + return "", err
|
| + }
|
| + return s, nil
|
| +}
|
|
|