Documentation
¶
Overview ¶
Package normalize is a set of tools for cleaning up URL s and formatting nostr OK and CLOSED messages.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( WS = []byte("ws://") WSS = []byte("wss://") HTTP = []byte("http://") HTTPS = []byte("https://") )
Functions ¶
func Msg ¶
Msg constructs a properly formatted message with a machine-readable prefix for OK and CLOSED envelopes.
func MsgString ¶
MsgString constructs a properly formatted message with a machine-readable prefix for OK and CLOSED envelopes.
func URL ¶
func URL[V constraints.Bytes](v V) (b []byte)
URL normalizes the URL
- Adds wss:// to addresses without a port, or with 443 that have no protocol prefix
- Adds ws:// to addresses with any other port
- Converts http/s to ws/s
Types ¶
type Reason ¶
type Reason []byte
Reason is the machine-readable prefix before the colon in an OK or CLOSED envelope message. Below are the most common kinds that are mentioned in NIP-01.
func (Reason) Errorf ¶
Errorf allows creation of a full Reason text with a printf style as an error.