Skip to content

Latest commit

 

History

History
30 lines (19 loc) · 619 Bytes

readme.md

File metadata and controls

30 lines (19 loc) · 619 Bytes

Strip Common Prefixes

Strip common prefixes, that we don't need to display to the user, from hostnames.

Installation

npm install --save @ctrlpanel/strip-common-prefixes

Usage

const stripCommonPrefixes = require('@ctrlpanel/strip-common-prefixes')

console.log(stripCommonPrefixes('auth.example.com'))
//=> example.com

console.log(stripCommonPrefixes('www.example.com'))
//=> example.com

console.log(stripCommonPrefixes('hotels.example.com'))
//=> hotels.example.com

API

stripCommonPrefixes(hostname) => string

Returns the same hostname, but with common prefixes stripped.