urlprotocol

package
v0.31.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 4, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package urlprotocol classifies a Git URL by the transport it names.

Split out of pkg/repository/url so it can be used from pkg/render, which must stay importable without dragging in a dependency graph: the rest of pkg/repository/url reaches oklog/ulid, samber/lo and golang.org/x/text, none of which a template needs to decide whether a fork URL is SSH-form. pkg/repository/url re-exports everything here, so its own callers are unaffected.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UsingHTTPBasedProtocol

func UsingHTTPBasedProtocol(unparsedURL string) bool

func UsingSSHBasedProtocol

func UsingSSHBasedProtocol(unparsedURL string) bool

Types

type Parsed

type Parsed struct {
	Protocol Protocol
	Host,
	Owner,
	Repository string
}

Parsed is a Git URL broken into its parts.

The type lives here rather than in pkg/repository/url for the same reason the protocol constants do: pkg/config embeds it, and that package must stay importable without pulling the parsing machinery — which reaches oops, samber/lo and golang.org/x/text — along with it. pkg/repository/url aliases it and owns Parse.

func (*Parsed) AsHTTPsURL

func (u *Parsed) AsHTTPsURL() string

AsHTTPsURL renders the URL in https form, whatever transport it was written in.

func (*Parsed) HostName

func (u *Parsed) HostName() string

HostName is Host without any port.

type Protocol

type Protocol string
const (
	ProtocolHTTP  Protocol = "HTTP"
	ProtocolHTTPs Protocol = "HTTPs"
	ProtocolSSH   Protocol = "SSH"
	ProtocolSCP   Protocol = "SCP"
)

func DetectProtocol

func DetectProtocol(unparsedURL string) Protocol

DetectProtocol reports which transport unparsedURL names. Anything that does not carry an explicit http/https/ssh scheme is treated as SCP, which is how "git@host:path" shorthand is classified.

type Scheme

type Scheme string
const (
	SchemeHTTP  Scheme = "http://"
	SchemeHTTPs Scheme = "https://"
	SchemeSSH   Scheme = "ssh://"
	SchemeSCP   Scheme = "scp://"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL