Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

capitalize-title

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

capitalize-title

Properly capitalize article titles

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Capitalize Title

Properly capitalize an article or blog title in Javascript. Code adapted from this post from John Resig in 2008 http://ejohn.org/blog/title-capitalization-in-javascript/.

Rules

  • Doesn't capitalize certain small words (a, an, and, as, at, but, by, en, for, if, in, of, on, or, the, to, v, via, vs)
  • Doesn't change words when they have other letters than the first capitalized, eg. iTunes
  • Skips words with dots, eg example.com
  • First and last word of the title are always capitalized, except for the previous two rules
  • A small word after a colon will be capitalized

Installation

npm i capitalize-title -s
yarn add capitalize-title

Usage

  import capitalizeTitle from 'capitalize-title';
  console.log(capitalizeTitle('this is an example title'));
  // > "This is an Example Title"

License

MIT

Keywords

FAQs

Package last updated on 05 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc