Skip to content

Commit

Permalink
refactor: use replaceAll instead of replace with a regex
Browse files Browse the repository at this point in the history
  • Loading branch information
Phillip9587 committed Feb 6, 2025
1 parent 5996f03 commit 9ca5acd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
1 change: 1 addition & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ unreleased
* remove unnecessary devDependency `safe-buffer`
* remove `unpipe` package and use native `unpipe()` method
* remove unnecessary devDependency `readable-stream`
* refactor: use replaceAll instead of replace with a regex

v2.0.0 / 2024-09-02
==================
Expand Down
7 changes: 2 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ var statuses = require('statuses')
* @private
*/

var DOUBLE_SPACE_REGEXP = /\x20{2}/g
var NEWLINE_REGEXP = /\n/g

var isFinished = onFinished.isFinished

/**
Expand All @@ -37,8 +34,8 @@ var isFinished = onFinished.isFinished

function createHtmlDocument (message) {
var body = escapeHtml(message)
.replace(NEWLINE_REGEXP, '<br>')
.replace(DOUBLE_SPACE_REGEXP, ' &nbsp;')
.replaceAll('\n', '<br>')
.replaceAll(' ', ' &nbsp;')

return '<!DOCTYPE html>\n' +
'<html lang="en">\n' +
Expand Down

0 comments on commit 9ca5acd

Please sign in to comment.