safelinks

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package safelinks provides functionality for decoding Safe Links URLs to their original values.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidURL indicates that an invalid URL was provided.
	ErrInvalidURL = errors.New("invalid URL provided")

	// ErrOriginalURLNotResolved indicates that we failed to resolve the
	// original URL using the given Safe Links URL.
	ErrOriginalURLNotResolved = errors.New("unable to resolve original URL")
)

Functions

func ProcessInputAsURL

func ProcessInputAsURL(inputURL string) ([]string, error)

ProcessInputAsURL processes a given input string as a URL value. This input string represents a single URL given via CLI flag.

If an input string is not provided, this function will attempt to read input URLs from stdin. Each input URL is unescaped and quoting removed.

The collection of input URLs is returned or an error if one occurs.

func ProcessInputURLs

func ProcessInputURLs(inputURLs []string, okOut io.Writer, errOut io.Writer, verbose bool) bool

ProcessInputURLs processes a given collection of input URL strings and emits successful decoding results to the specified results output sink. Errors are emitted to the specified error output sink if encountered but bulk processing continues until all input URLs have been evaluated.

If requested, decoded URLs are emitted in verbose format.

A boolean value is returned indicating whether any errors occurred.

func ReadURLFromUser

func ReadURLFromUser() (string, error)

ReadURLFromUser attempts to read a given URL pattern from the user via stdin prompt.

func ReadURLsFromFile

func ReadURLsFromFile(r io.Reader) ([]string, error)

ReadURLsFromFile attempts to read URL patterns from a given file (io.Reader).

The collection of input URLs is returned or an error if one occurs.

Types

This section is empty.

Jump to

Keyboard shortcuts

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