stringutil

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package stringutil provides string utility functions.

Index

Constants

View Source
const (
	PasswordDummy = "•"
)

Variables

This section is empty.

Functions

func ComputeRecipients

func ComputeRecipients(
	from, to, cc, bcc []string,
	contactEmail, inboxEmail string,
	lastMessageIncoming bool,
) (finalTo, finalCC, finalBCC []string)

ComputeRecipients computes new recipients using last message's recipients and direction.

func DedupAndExcludePlusVariants

func DedupAndExcludePlusVariants(list []string, inboxEmail string) []string

DedupAndExcludePlusVariants deduplicates and excludes inbox email and its plus-addressed variants.

func DedupAndExcludeString

func DedupAndExcludeString(list []string, exclude string) []string

DedupAndExcludeString returns a deduplicated []string excluding empty and a specific value.

func ExtractConvUUID

func ExtractConvUUID(email string) string

ExtractConvUUID extracts the conversation UUID from a plus-addressed email. e.g., support+conv-abc12345-1234-4123-1234-123456789abc@domain.com -> abc12345-1234-4123-1234-123456789abc Returns empty string if no valid UUIDv4 found.

func ExtractEmail

func ExtractEmail(s string) (string, error)

ExtractEmail extracts the email address from a string.

func ExtractReferenceNumber

func ExtractReferenceNumber(subject string) string

ExtractReferenceNumber extracts the last reference number from a subject line. For example, "RE: Test - #392" returns "392". If multiple numbers exist (e.g., "Order #123 - #392"), returns the last one ("392").

func FormatDuration

func FormatDuration(d time.Duration, includeSeconds bool) string

FormatDuration formats a duration as a string.

func GenerateEmailMessageID

func GenerateEmailMessageID(messageID string, fromAddress string) (string, error)

GenerateEmailMessageID generates a RFC-compliant Message-ID for an email, does not include the angle brackets. The client is expected to wrap the returned string in angle brackets.

func GetPathFromURL

func GetPathFromURL(u string) (string, error)

GetPathFromURL extracts the path from a URL.

func HTML2Text

func HTML2Text(html string) string

HTML2Text converts HTML to text.

func RandomAlphanumeric

func RandomAlphanumeric(n int) (string, error)

RandomAlphanumeric generates a random alphanumeric string of length n.

func RandomNumeric

func RandomNumeric(n int) (string, error)

RandomNumeric generates a random numeric string of length n.

func RemoveEmpty

func RemoveEmpty(s []string) []string

RemoveEmpty removes empty strings from a slice of strings.

func RemoveItemByValue

func RemoveItemByValue(slice []string, value string) []string

RemoveItemByValue removes all instances of a value from a slice of strings.

func SanitizeFilename

func SanitizeFilename(fName string) string

SanitizeFilename sanitizes the provided filename.

func StripConvUUID

func StripConvUUID(email string) string

StripConvUUID removes +conv-{uuid-v4} from an email address if present. Only matches strict UUID v4 format (36 chars). e.g., support+conv-13216cf7-6626-4b0d-a938-46ce65a20701@domain.com -> support@domain.com

func ValidEmail

func ValidEmail(email string) bool

ValidEmail returns true if it's a valid email else return false.

Types

This section is empty.

Jump to

Keyboard shortcuts

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