pkgurl

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package pkgurl contains functions for parsing remote urls

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindScpLikeComponents

func FindScpLikeComponents(url string) (user, host, port, path, hash string)

FindScpLikeComponents returns the user, host, port and path of the given SCP-like URL.

func IsLocalEndpoint

func IsLocalEndpoint(url string) bool

IsLocalEndpoint returns true if the given URL string specifies a local file endpoint. For example, on a Linux machine, `/home/user/src/go-git` would match as a local endpoint, but `https://github.com/src-d/go-git` would not.

func IsRemoteEndpoint

func IsRemoteEndpoint(url string) bool

IsRemoteEndpoint returns true if the giver URL string specifies a remote endpoint. For example, on a Linux machine, `https://github.com/src-d/go-git` would match as a remote endpoint, but `/home/user/src/go-git` would not.

func MatchesScheme

func MatchesScheme(url string) bool

MatchesScheme returns true if the given string matches a URL-like format scheme.

func MatchesScpLike

func MatchesScpLike(url string) bool

MatchesScpLike returns true if the given string matches an SCP-like format scheme.

Types

type Parts added in v0.5.0

type Parts struct {
	GitUser string
	Host    string
	Port    string
	Path    string

	// Fragment is the part of the URL after the hash (#)
	Fragment string
	Version  string
}

func Parse added in v0.5.0

func Parse(strURL string) (Parts, error)

func (Parts) PathParts added in v0.5.0

func (p Parts) PathParts() []string

func (Parts) RepoOwnerAndName added in v0.5.0

func (p Parts) RepoOwnerAndName() (user, repo string, ok bool)

RepoOwnerAndName returns the owner and name of the repository if the URL path contains at least two parts. Otherwise, it returns false.

Example:

  • Path="hay-kot/scaffold-go-cli" => user="hay-kot", repo="scaffold-go-cli", ok=true
  • Path="hay-kot" => user="", repo="", ok=false

Jump to

Keyboard shortcuts

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