Skip to content

Commit 387afd7

Browse files
committed
[Robustness] formats: cache String#replace
1 parent 35a6f09 commit 387afd7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/formats.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
'use strict';
22

3+
var replace = String.prototype.replace;
4+
var percentTwenties = /%20/g;
5+
36
module.exports = {
47
'default': 'RFC3986',
58
formatters: {
69
RFC1738: function (value) {
7-
return String(value).replace(/%20/g, '+');
10+
return replace.call(value, percentTwenties, '+');
811
},
912
RFC3986: function (value) {
1013
return value;

0 commit comments

Comments
 (0)