1 |
|
2 | /**
|
3 | * Return an ETag in the form of `"<size>-<mtime>"`
|
4 | * from the given `stat`.
|
5 | *
|
6 | * @param {Object} stat
|
7 | * @return {String}
|
8 | * @api private
|
9 | */
|
10 |
|
11 | exports.etag = function(stat) {
|
12 | return '"' + stat.size + '-' + Number(stat.mtime) + '"';
|
13 | };
|
14 |
|
15 | /**
|
16 | * decodeURIComponent.
|
17 | *
|
18 | * Allows V8 to only deoptimize this fn instead of all
|
19 | * of send().
|
20 | *
|
21 | * @param {String} path
|
22 | * @api private
|
23 | */
|
24 |
|
25 | exports.decode = function(path){
|
26 | try {
|
27 | return decodeURIComponent(path);
|
28 | } catch (err) {
|
29 | return -1;
|
30 | }
|
31 | };
|
32 |
|
33 | /**
|
34 | * Escape the given string of `html`.
|
35 | *
|
36 | * @param {String} html
|
37 | * @return {String}
|
38 | * @api private
|
39 | */
|
40 |
|
41 | exports.escape = function(html){
|
42 | return String(html)
|
43 | .replace(/&(?!\w+;)/g, '&')
|
44 | .replace(/</g, '<')
|
45 | .replace(/>/g, '>')
|
46 | .replace(/"/g, '"');
|
47 | }; |
\ | No newline at end of file |