pinterest-url-normalizer

Parse, classify, and normalize Pinterest URLs in Ruby without making network requests.

SavePinner · RubyGems · RubyDoc.info · npm · PyPI · crates.io · Packagist · Go

The gem recognizes Pin, pin.it, profile, board, and Ideas URLs across Pinterest country domains. It uses an exact host allow list, rejects HTTP URLs and lookalike domains, and removes query parameters and fragments from normalized output.

Install

gem install pinterest-url-normalizer

Library

require "pinterest_url_normalizer"

parsed = PinterestURLNormalizer.parse(
  "https://de.pinterest.com/pin/987654321/?utm_source=share"
)

parsed.pin_id
# => "987654321"

parsed.normalized_url
# => "https://www.pinterest.com/pin/987654321/"

CLI

pinterest-url-normalizer \
  "https://de.pinterest.com/pin/987654321/?utm_source=share" \
  "https://pin.it/AbC123"

Read one URL per line and emit JSON Lines:

printf '%s\n' 'https://www.pinterest.com/pin/123/' | \
  pinterest-url-normalizer --json

The process exits with status 1 when any input is invalid and status 2 for usage errors.

Supported URLs

Kind Example
Pin https://www.pinterest.com/pin/123456789/
Short https://pin.it/AbC123
Profile https://www.pinterest.com/savepinner/
Board https://www.pinterest.com/savepinner/media-tools/
Ideas https://www.pinterest.com/ideas/space-wallpaper/926295399832/

pin.it links are classified and normalized but are not followed. Resolving them requires a network request and belongs in the consuming application.

License

MIT