@@ -14,7 +14,6 @@ var os = require('os');
1414var path = require ( 'path' ) ;
1515var qs = require ( 'querystring' ) ;
1616var url = require ( 'url' ) ;
17- var utils = require ( './utils.js' ) ;
1817var uuid = require ( 'node-uuid' ) ;
1918var debug = require ( 'debug' ) ( 'miniprofiler' ) ;
2019
@@ -72,13 +71,15 @@ var contentTypes = {
7271} ;
7372function static ( reqPath , res ) {
7473 fs . readFile ( path . join ( includesDir , reqPath ) , function ( err , data ) {
75- if ( err ) {
74+ if ( err ) {
75+ debug ( err ) ;
76+ res . setHeader ( 'Content-Type' , 'text/html' ) ;
7677 res . writeHead ( 404 ) ;
77- res . end ( JSON . stringify ( err ) ) ;
78+ res . end ( 'Resource unavailable.' ) ;
7879 return ;
7980 }
8081 var rs = reqPath . split ( '.' ) ;
81- res . setHeader ( " Content-Type" , contentTypes [ rs [ rs . length - 1 ] ] ) ;
82+ res . setHeader ( ' Content-Type' , contentTypes [ rs [ rs . length - 1 ] ] ) ;
8283 res . writeHead ( 200 ) ;
8384 res . end ( data ) ;
8485 } ) ;
@@ -89,11 +90,11 @@ function results(req, res) {
8990 // todo: store client timings
9091 var id = post . id || url . parse ( req . url , true ) . query . id ;
9192 var s = storage ( id ) ;
92- if ( post . popup == "1" )
93+ if ( post . popup == '1' )
9394 res . end ( s ) ;
9495 else {
9596 var j = JSON . parse ( s ) ;
96- res . setHeader ( " Content-Type" , " text/html" ) ;
97+ res . setHeader ( ' Content-Type' , ' text/html' ) ;
9798 res . end ( includes . share ( {
9899 name : j . Name ,
99100 duration : j . DurationMilliseconds ,
@@ -155,7 +156,7 @@ function middleware(f) {
155156 res . on ( 'finish' , function ( ) {
156157 stopProfiling ( req ) ;
157158 } ) ;
158- res . setHeader ( " X-MiniProfiler-Ids" , '["' + id + '"]' ) ;
159+ res . setHeader ( ' X-MiniProfiler-Ids' , '["' + id + '"]' ) ;
159160 }
160161 next ( ) ;
161162 } ;
@@ -223,7 +224,7 @@ function addProfilingInstrumentation(toInstrument) {
223224 throw new Error ( 'toInstrument must be set' ) ;
224225 }
225226
226- if ( ! utils . isObject ( toInstrument ) ) {
227+ if ( ! _ . isObject ( toInstrument ) ) {
227228 throw new Error ( 'toInstrument must be an object' ) ;
228229 }
229230
@@ -361,7 +362,7 @@ function timeQuery(extension, type, query, executeFunction) {
361362 var customTiming = {
362363 id : uuid . v4 ( ) ,
363364 executeType : type ,
364- commandString : utils . htmlEscape ( query ) ,
365+ commandString : _ . escape ( query ) ,
365366 startTime : time ,
366367 startDate : startDate ,
367368 callStack : new Error ( ) . stack
@@ -370,7 +371,7 @@ function timeQuery(extension, type, query, executeFunction) {
370371
371372 for ( var i = 0 ; i < params . length ; i ++ ) {
372373 var param = params [ i ] ;
373- if ( utils . isFunction ( params [ i ] ) ) {
374+ if ( _ . isFunction ( params [ i ] ) ) {
374375 params [ i ] = function ( ) {
375376 customTiming . stopTime = process . hrtime ( ) ;
376377
@@ -503,7 +504,7 @@ function instrument(func, defaultName) {
503504 if ( args ) {
504505 for ( var i = 0 ; i < args . length ; i ++ ) {
505506 var arg = args [ i ] ;
506- if ( arg && utils . isFunction ( arg ) ) {
507+ if ( arg && _ . isFunction ( arg ) ) {
507508 args [ i ] = instrument ( arg , name + ' arg #' + i ) ;
508509 }
509510 }
@@ -549,13 +550,13 @@ function addProfilingImpl(toInstrument) {
549550 continue ;
550551 }
551552
552- if ( utils . isObject ( toWrap ) ) {
553+ if ( _ . isObject ( toWrap ) ) {
553554 addProfilingImpl ( toWrap ) ;
554555
555556 continue ;
556557 }
557558
558- if ( utils . isFunction ( toWrap ) ) {
559+ if ( _ . isFunction ( toWrap ) ) {
559560 var wrappedFunc = instrument ( toWrap , prop ) ;
560561
561562 toInstrument [ prop ] = wrappedFunc ;
0 commit comments