npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

keeplist-social

v1.0.3

Published

Cross-platform library for validating and sanitizing social media profile URLs

Downloads

219

Readme

Keeplist Social

TypeScript Tests Dart Tests npm version Pub Version

A cross-platform library for validating, sanitizing, and standardizing social media profile URLs and identifiers. Available for TypeScript/JavaScript and Dart/Flutter.

Credits:

  • This project is inspired by and based on social-links by Grzegorz Kućmierz. We've expanded it to support multiple platforms and plan to evolve it further.
  • Development was assisted by Cursor using Claude-3.5-20241022.

Note: This is currently an MVP (Minimum Viable Product) version. A complete rewrite in Rust is planned, which will:

  • Use WebAssembly (WASM) for cross-language compatibility
  • Enable single-source-of-truth implementation
  • Support multiple language bindings through WASM
  • Reduce maintenance overhead of multiple implementations

Purpose

Keeplist Social solves several common problems when working with social media URLs:

  1. URL Validation: Verify if a URL is a valid social media profile link
  2. Profile ID Extraction: Extract the unique identifier from various URL formats
  3. URL Standardization: Convert different URL formats to a canonical form
  4. Cross-Platform Support: Works in both web and mobile environments

Features

  • Supports 25+ social platforms including:

    • Major social networks (Twitter/X, Facebook, Instagram, LinkedIn)
    • Professional platforms (GitHub, StackOverflow, Dev.to)
    • Media platforms (YouTube, Spotify, Apple Podcasts)
    • Messaging platforms (Discord, Telegram, WhatsApp)
    • And many more
  • Handles various URL formats:

    • Different protocols (http, https)
    • With/without www prefix
    • Mobile URLs (m.example.com)
    • Country-specific domains
    • With/without trailing slashes
    • Query parameters (optional)

Usage

TypeScript/JavaScript

import { SocialLinks } from 'keeplist-social';

const social = await SocialLinks.create();

// Validate URLs
social.isValid('twitter', 'https://x.com/username');  // true
social.isValid('twitter', 'not-a-url');  // false

// Extract profile IDs
social.getProfileId('github', 'https://github.com/username');  // 'username'

// Standardize URLs
social.sanitize('linkedin', 'www.linkedin.com/in/username');  
// Returns: 'https://linkedin.com/in/username'

Dart/Flutter

import 'package:social/social.dart';

final social = await SocialLinks.create();

// Validate URLs
social.isValid('twitter', 'https://x.com/username');  // true

// Extract profile IDs
social.getProfileId('github', 'https://github.com/username');  // 'username'

// Standardize URLs
social.sanitize('linkedin', 'www.linkedin.com/in/username');
// Returns: 'https://linkedin.com/in/username'

Configuration

const social = await SocialLinks.create({
  trimInput: true,              // Trim whitespace from inputs
  filterForQueryParams: false,  // Allow/strip query parameters
});

Adding New Platforms

Platforms are defined in JSON pattern files under /patterns:

{
  "name": "platform_name",
  "matches": [
    {
      "match": "(https?://)?([\\w.]*\\.)?platform\\.com/({PROFILE_ID})/?",
      "group": 3,
      "pattern": "https://platform.com/{PROFILE_ID}"
    }
  ]
}

Development

  1. Install dependencies:
# For TypeScript
npm install

# For Dart
flutter pub get
  1. Run tests:
# TypeScript
npm test

# Dart
flutter test

Publishing

NPM Package

  1. Update version in ts/package.json
  2. Build the package:
cd ts
npm run build
  1. Publish to NPM:
npm publish

Dart/Flutter Package

  1. Update version in dart/pubspec.yaml
  2. Run tests:
cd dart
flutter test
  1. Publish to pub.dev:
flutter pub publish

Installation

NPM

npm install keeplist-social

Dart/Flutter

Add to your pubspec.yaml:

dependencies:
  keeplist_social: ^1.0.0

Then run:

flutter pub get

License

MIT License

Future Plans

Rust + WebAssembly Implementation

The current TypeScript and Dart implementations serve as a proof of concept. The next major version will:

  1. Rewrite the core functionality in Rust

  2. Compile to WebAssembly for:

    • JavaScript/TypeScript (via wasm-bindgen)
    • Dart/Flutter (via flutter_rust_bridge)
    • Python (via PyO3)
    • Other languages as needed
  3. Provide improved features:

    • Better performance
    • Smaller package size
    • Type-safe bindings
    • Unified test suite
    • Easier maintenance

Stay tuned for updates on the Rust implementation!