Help us shape the future of Go! Take the 2026 Go Developer Survey

urlarg

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package urlarg provides utilities for parsing Basecamp URLs into IDs. This allows users to paste URLs from the browser as command arguments.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractCommentWithProject

func ExtractCommentWithProject(arg string) (id, projectID string, err error)

ExtractCommentWithProject extracts a comment ID and project ID from an argument. For URLs with a fragment (e.g., #__recording_789), returns the comment ID. For URLs without a fragment, returns the recording ID (same as ExtractWithProject). Returns (commentOrRecordingID, projectID).

func ExtractID

func ExtractID(arg string) (string, error)

ExtractID extracts the primary ID from an argument. If the argument is a Basecamp URL, extracts the recording ID. Otherwise, returns the argument as-is (assumed to be an ID).

func ExtractIDs

func ExtractIDs(args []string) ([]string, error)

ExtractIDs extracts IDs from multiple arguments, handling URLs and comma-separated values (e.g. "123,456,789"). One occurrence URL refuses them all, before the caller acts on any.

func ExtractProjectID

func ExtractProjectID(arg string) string

ExtractProjectID extracts the project (bucket) ID from an argument. If the argument is a Basecamp URL, extracts the bucket ID. Otherwise, returns the argument as-is.

func ExtractWithProject

func ExtractWithProject(arg string) (recordingID, projectID string, err error)

ExtractWithProject extracts both the recording ID and project ID from an argument. Returns (recordingID, projectID). If projectID is empty, it wasn't in the URL.

func IsURL

func IsURL(input string) bool

IsURL checks if the input looks like a Basecamp URL. Returns true if the URL can be matched (either as an API route or structurally).

Types

type OccurrenceError added in v0.18.0

type OccurrenceError struct {
	EntryID string
	Date    string
	URL     string // the occurrence's URL, without any comment fragment
}

OccurrenceError reports a URL that names one occurrence of a recurring schedule entry. The occurrence is a recording of its own and the API cannot change it, so the extractors refuse the URL rather than return the entry's ID, which would act on the whole series.

func (*OccurrenceError) Error added in v0.18.0

func (e *OccurrenceError) Error() string

type Parsed

type Parsed struct {
	AccountID      string
	ProjectID      string // BucketID in Basecamp terminology
	Type           string // e.g., "todos", "messages", "cards"
	RecordingID    string
	CampfireID     string // parent campfire ID for chat-line URLs (chats/{campfireId}/lines/{lineId})
	PingID         string // the Ping (a Circle bucket) named by circles/{pingId} and circles/{pingId}@{lineId} URLs
	CommentID      string
	IsCollection   bool   // URL points to a list of items, not an individual resource
	OccurrenceDate string // date from schedule_entries/{id}/occurrences/{date} URLs
}

Parsed represents components extracted from a Basecamp URL.

func Parse

func Parse(input string) *Parsed

Parse extracts IDs from a Basecamp URL. Returns nil if the input is not a valid Basecamp URL, if its path goes past the item it names to another one Parse does not model, or if the ID it ends in is a person's or an embed's, so that callers refuse it rather than act on the wrong recording.

Supported URL patterns:

Jump to

Keyboard shortcuts

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