Skip to content
Myr

replace utils.escape with html-escape

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Douglas Christopher Wilson · committed by Douglas Christopher Wilson · parent a94278a · Browse files · 4 files+3 added−24 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+3 added−24 removed

  • tests:+0 added−7 removed
  • other:+3 added−17 removed

4 files+3 added−24 removed

modified:lib/response.js+2 added-1 removed
1/**2 * Module dependencies.3 */45var escapeHtml = require('escape-html');6var http = require('http')7 , path = require('path')8 , connect = require('connect')9 , utils = connect.utils
734 unmodified lines
744 body = statusCodes[status] + '. Redirecting to ' + encodeURI(url);745 },746747 html: function(){747 var u = utils.escape(url);748 var u = escapeHtml(url);749 body = '<p>' + statusCodes[status] + '. Redirecting to <a href="' + u + '">' + u + '</a></p>';750 },751752 default: function(){
87 unmodified lines
modified:lib/utils.js-16 removed
321 unmodified lines
322 return ret;323}324325/**326 * Escape special characters in the given string of html.327 *328 * @param {String} html329 * @return {String}330 * @api private331 */332333exports.escape = function(html) {334 return String(html)335 .replace(/&/g, '&amp;')336 .replace(/"/g, '&quot;')337 .replace(/</g, '&lt;')338 .replace(/>/g, '&gt;');339};340341/**326 * Normalize the given path string,327 * returning a regular expression.328 *329 * An empty array should be passed,
127 unmodified lines
modified:test/utils.js-7 removed
92 unmodified lines
93 .should.eql(['one', 'two', 'three', 'four', 'five']);94 })95})9697describe('utils.escape(html)', function(){98 it('should escape html entities', function(){99 utils.escape('<script>foo & "bar"')100 .should.equal('&lt;script&gt;foo &amp; &quot;bar&quot;')101 })102})10397describe('utils.parseParams(str)', function(){98 it('should default quality to 1', function(){99 utils.parseParams('text/html')100 .should.eql([{ value: 'text/html', quality: 1, params: {}, originalIndex: 0 }]);
172 unmodified lines
modified:package.json+1 added