slinky

package module
v0.0.0-...-e74a138 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2026 License: BSD-3-Clause Imports: 4 Imported by: 0

README

Slinky

Go Reference

Parse social media URLs in Go.

Usage

slinky.Parse("https://github.com/hjr265")
// Output:
// 	&URL{
// 		Service: slinky.GitHub,
// 		Type:    "User",
// 		ID:      "hjr265",
// 		Data:    map[string]string{
// 			"username": "hjr265",
// 		},
//	}

URLs Supported

// Bandcamp
"*.bandcamp.com"

// Behance
"behance.net"
"www.behance.net"

// Bitbucket
"bitbucket.org"

// Bluesky
"bsky.app"

// Codeberg
"codeberg.org"

// DeviantArt
"deviantart.com"
"www.deviantart.com"

// Dribbble
"dribbble.com"
"www.dribbble.com"

// Facebook
"facebook.com"
"www.facebook.com"
"web.facebook.com"
"m.facebook.com"
"fb.me"

// FLOSS.social
"floss.social"

// Fostodon
"fosstodon.org"

// Mastodon
"mastodon.social"

// GitHub
"github.com"
"*.github.io"

// GitLab
"gitlab.com"
"www.gitlab.com"

// Goodreads
"goodreads.com"
"www.goodreads.com"

// Kick
"kick.com"
"www.kick.com"

// Ko-fi
"ko-fi.com"

// Instagram
"instagram.com"
"www.instagram.com"
"m.instagram.com"

// Letterboxd
"letterboxd.com"
"www.letterboxd.com"

// LinkedIn
"linkedin.com"
"www.linkedin.com"

// Medium
"medium.com"
"www.medium.com"

// Messenger
"m.me"
"www.m.me"

// Patreon
"patreon.com"
"www.patreon.com"

// Signal
"signal.me"

// Snapchat
"snapchat.com"
"www.snapchat.com"

// Sourcehut
"sr.ht"

// SoundCloud
"soundcloud.com"
"www.soundcloud.com"

// Spotify
"open.spotify.com"

// Substack
"*.substack.com"

// Reddit
"reddit.com"
"www.reddit.com"
"old.reddit.com"

// Pinterest
"pinterest.com"
"www.pinterest.com"

// Vimeo
"vimeo.com"
"www.vimeo.com"

// TikTok
"tiktok.com"
"www.tiktok.com"

// Threads
"threads.net"
"www.threads.net"

// Steam
"steamcommunity.com"
"www.steamcommunity.com"

// Telegram
"t.me"
"telegram.me"

// Toph
"toph.co"

// Tumblr
"tumblr.com"
"www.tumblr.com"
"*.tumblr.com"

// Twitch
"twitch.tv"
"www.twitch.tv"
"twitch.com"
"www.twitch.com"

// Twitter
"x.com"
"www.x.com"
"twitter.com"
"www.twitter.com"

// WhatsApp
"wa.me"
"www.wa.me"

// YouTube
"youtube.com"
"www.youtube.com"
"m.youtube.com"

Contributing

Contributions are welcome.

License

Slinky is available under the BSD (3-Clause) License.

Documentation

Overview

Package slinky parses social media URLs and extracts structured information such as the service name, profile type, and username or identifier.

It supports a wide range of platforms including Facebook, GitHub, GitLab, Instagram, LinkedIn, Mastodon, Reddit, Snapchat, Spotify, TikTok, Twitch, Twitter/X, YouTube, and many more.

Usage:

u, err := slinky.Parse("https://github.com/hjr265")
// u.Service == slinky.GitHub
// u.Type == "User"
// u.ID == "hjr265"
// u.Data["username"] == "hjr265"

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotAbsolute is returned when the URL does not have a scheme.
	ErrNotAbsolute = errors.New("url is not absolute")

	// ErrUnknownService is returned when the URL does not match any known social media service.
	ErrUnknownService = errors.New("url belongs to an unknown service")

	// ErrInvalidURL is returned when the URL matches a known service but has an invalid format.
	ErrInvalidURL = errors.New("invalid URL")
)

Functions

This section is empty.

Types

type Service

type Service string

Service identifies a social media service.

const (
	Bandcamp    Service = "Bandcamp"
	Behance     Service = "Behance"
	Bitbucket   Service = "Bitbucket"
	Bluesky     Service = "Bluesky"
	Codeberg    Service = "Codeberg"
	DeviantArt  Service = "DeviantArt"
	Dribbble    Service = "Dribbble"
	Facebook    Service = "Facebook"
	FLOSSSocial Service = "FLOSSSocial"
	Fosstodon   Service = "Fosstodon"
	GitHub      Service = "GitHub"
	GitLab      Service = "GitLab"
	Goodreads   Service = "Goodreads"
	Instagram   Service = "Instagram"
	Kick        Service = "Kick"
	Kofi        Service = "Kofi"
	Letterboxd  Service = "Letterboxd"
	LinkedIn    Service = "LinkedIn"
	Mastodon    Service = "Mastodon"
	Medium      Service = "Medium"
	Messenger   Service = "Messenger"
	Patreon     Service = "Patreon"
	Pinterest   Service = "Pinterest"
	Reddit      Service = "Reddit"
	Signal      Service = "Signal"
	Snapchat    Service = "Snapchat"
	Sourcehut   Service = "Sourcehut"
	SoundCloud  Service = "SoundCloud"
	Spotify     Service = "Spotify"
	Steam       Service = "Steam"
	Substack    Service = "Substack"
	Telegram    Service = "Telegram"
	Threads     Service = "Threads"
	TikTok      Service = "TikTok"
	Toph        Service = "Toph"
	Tumblr      Service = "Tumblr"
	Twitch      Service = "Twitch"
	Twitter     Service = "Twitter"
	Vimeo       Service = "Vimeo"
	WhatsApp    Service = "WhatsApp"
	YouTube     Service = "YouTube"
)

Supported social media services.

type URL

type URL struct {
	Service Service
	Type    string
	ID      string
	Data    map[string]string
	URL     *url.URL
}

A URL represents a parsed social media URL.

func Parse

func Parse(rawURL string) (*URL, error)

Parse parses a raw url into a URL structure.

The url must be absolute (starting with a scheme).

Example
package main

import (
	"fmt"

	"github.com/FurqanSoftware/slinky"
)

func main() {
	u, err := slinky.Parse("https://github.com/hjr265")
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(u.Service)
	fmt.Println(u.Type)
	fmt.Println(u.ID)
	fmt.Println(u.Data["username"])
}
Output:
GitHub
User
hjr265
hjr265

Jump to

Keyboard shortcuts

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