Skip to content

Commit

Permalink
fix: even better regex for host fragment (#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
wraithgar authored Nov 21, 2024
1 parent 1547692 commit cc004ba
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/hosts.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const maybeJoin = (...args) => args.every(arg => arg) ? args.join('') : ''
const maybeEncode = (arg) => arg ? encodeURIComponent(arg) : ''
const formatHashFragment = (f) => f.toLowerCase()
.replace(/^\W+/g, '') // strip leading non-characters
.replace(/\W+$/g, '') // strip trailing non-characters
.replace(/(?<!\W)\W+$/, '') // strip trailing non-characters
.replace(/\//g, '') // strip all slashes
.replace(/\W+/g, '-') // replace remaining non-characters with '-'

Expand Down

0 comments on commit cc004ba

Please sign in to comment.