Skip to content

Commit

Permalink
fix: use replaceAll instead of replace with a regex (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
Phillip9587 authored Feb 10, 2025
1 parent 0e5ecb4 commit 59a45ca
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 @@ -11,6 +11,7 @@ unreleased
* remove `unpipe` package and use native `unpipe()` method
* remove unnecessary devDependency `readable-stream`
* refactor: use object spread to copy error headers
* 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 59a45ca

Please sign in to comment.