Sha256: c7530d191d2158a28caa03e2b5a512a0783a4f3ab556908abeca6d7bbd8d0c59

Contents?: true

Size: 885 Bytes

Versions: 16

Compression:

Stored size: 885 Bytes

Contents

package http

import "strings"

// JoinPath returns an absolute URL path composed of the two paths provided.
// Enforces that the returned path begins with '/'. If added path is empty the
// returned path suffix will match the first parameter suffix.
func JoinPath(a, b string) string {
	if len(a) == 0 {
		a = "/"
	} else if a[0] != '/' {
		a = "/" + a
	}

	if len(b) != 0 && b[0] == '/' {
		b = b[1:]
	}

	if len(b) != 0 && len(a) > 1 && a[len(a)-1] != '/' {
		a = a + "/"
	}

	return a + b
}

// JoinRawQuery returns an absolute raw query expression. Any duplicate '&'
// will be collapsed to single separator between values.
func JoinRawQuery(a, b string) string {
	a = strings.TrimFunc(a, isAmpersand)
	b = strings.TrimFunc(b, isAmpersand)

	if len(a) == 0 {
		return b
	}
	if len(b) == 0 {
		return a
	}

	return a + "&" + b
}

func isAmpersand(v rune) bool {
	return v == '&'
}

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
ruby_snowflake_client-1.3.7 ext/vendor/github.com/aws/smithy-go/transport/http/url.go
ruby_snowflake_client-1.3.6 ext/vendor/github.com/aws/smithy-go/transport/http/url.go
ruby_snowflake_client-1.3.5 ext/vendor/github.com/aws/smithy-go/transport/http/url.go
ruby_snowflake_client-1.3.4 ext/vendor/github.com/aws/smithy-go/transport/http/url.go
ruby_snowflake_client-1.3.4.pre.debug ext/vendor/github.com/aws/smithy-go/transport/http/url.go
ruby_snowflake_client-1.3.3.pre.debug ext/vendor/github.com/aws/smithy-go/transport/http/url.go
ruby_snowflake_client-1.3.2 ext/vendor/github.com/aws/smithy-go/transport/http/url.go
ruby_snowflake_client-1.3.1 ext/vendor/github.com/aws/smithy-go/transport/http/url.go
ruby_snowflake_client-1.3.0 ext/vendor/github.com/aws/smithy-go/transport/http/url.go
ruby_snowflake_client-1.2.1 ext/vendor/github.com/aws/smithy-go/transport/http/url.go
ruby_snowflake_client-1.2.0 ext/vendor/github.com/aws/smithy-go/transport/http/url.go
ruby_snowflake_client-1.1.1 ext/vendor/github.com/aws/smithy-go/transport/http/url.go
ruby_snowflake_client-1.1.0 ext/vendor/github.com/aws/smithy-go/transport/http/url.go
ruby_snowflake_client-1.0.2 ext/vendor/github.com/aws/smithy-go/transport/http/url.go
ruby_snowflake_client-1.0.1 ext/vendor/github.com/aws/smithy-go/transport/http/url.go
ruby_snowflake_client-1.0.0 ext/vendor/github.com/aws/smithy-go/transport/http/url.go