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

reduce-user-agent

v1.0.3

Published

Remove repetitive patterns in User-Agent header

Downloads

83

Readme

reduce-user-agent

Remove repetitive patterns in User-Agent header.

npm i reduce-user-agent

Some common texts are:

  • Mozilla/5.0
  • AppleWebKit/*
  • (KHTML, like Gecko)
  • Safari/537.36
  • Gecko/*

It will also remove all kind of double or unnecessary spaces.

Usage

const reduceUA = require('reduce-user-agent')

const chrome = reduceUA('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36')
console.log(chrome) // => '(Windows NT 10.0; Win64; x64) Chrome/99.0.4844.51'

const firefox = reduceUA('Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:98.0) Gecko/20100101 Firefox/98.0')
console.log(firefox) // => '(Windows NT 10.0; Win64; x64; rv:98.0) Firefox/98.0'

const safari = reduceUA('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.3 Safari/605.1.15')
console.log(safari) // => '(Macintosh; Intel Mac OS X 10_15_7) Version/15.3 Safari/605.1.15'

const edge = reduceUA('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.74 Safari/537.36 Edg/99.0.1150.46')
console.log(edge) // => '(Windows NT 10.0; Win64; x64) Chrome/99.0.4844.74 Edg/99.0.1150.46'

const samsung = reduceUA('Mozilla/5.0 (Linux; Android 10; SAMSUNG SM-N975U1) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/11.0 Chrome/75.0.3770.143 Mobile Safari/537.36')
console.log(samsung) // => '(Linux; Android 10; SAMSUNG SM-N975U1) SamsungBrowser/11.0 Chrome/75.0.3770.143 Mobile'

const opera = reduceUA('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.109 Safari/537.36 OPR/84.0.4316.31')
console.log(opera) // => '(Windows NT 10.0; Win64; x64) Chrome/98.0.4758.109 OPR/84.0.4316.31'

const yandex = reduceUA('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.119 YaBrowser/22.3.0.2430 Yowser/2.5 Safari/537.36')
console.log(yandex) // => '(Windows NT 10.0; Win64; x64) Chrome/98.0.4758.119 YaBrowser/22.3.0.2430 Yowser/2.5'

License

MIT