Skip to content

Commit

Permalink
Rename String.printf() to String.sprintf()
Browse files Browse the repository at this point in the history
  • Loading branch information
nicwolff committed Feb 5, 2012
1 parent cefc4ab commit 7d1d9f0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions server.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var http = require('http'),


fs.stat( filename, function (error, stat) { fs.stat( filename, function (error, stat) {
if (error) { if (error) {
response.writeHead( 500, 'Error while reading %s: %s'.printf( resource, error ) ); response.writeHead( 500, 'Error while reading %s: %s'.sprintf( resource, error ) );
response.end(); response.end();
} else { } else {
var filesize = stat.size; var filesize = stat.size;
Expand Down Expand Up @@ -73,7 +73,7 @@ var http = require('http'),


console.log( 'Looking for files in ' + path ); console.log( 'Looking for files in ' + path );


String.prototype.printf = function () { String.prototype.sprintf = function () {
var args = arguments, i = 0; var args = arguments, i = 0;
return this.replace( /\%s/g, function () { return args[i++] } ); return this.replace( /\%s/g, function () { return args[i++] } );
} }
Expand All @@ -87,12 +87,12 @@ http.createServer( function (request, response) {
console.log( 'Illegal request for ' + resource ); console.log( 'Illegal request for ' + resource );
return; return;
} }
console.log( 'Routing request for %s to %s(%s)'.printf( request.url, method, resource ) ); console.log( 'Routing request for %s to %s(%s)'.sprintf( request.url, method, resource ) );
var h; var h;
if ( h = handlers[ method ] ) { if ( h = handlers[ method ] ) {
h( resource, request, response ); h( resource, request, response );
} else { } else {
response.writeHead( 405, 'Method %s not allowed on resource %s'.printf( method, resource ) ); response.writeHead( 405, 'Method %s not allowed on resource %s'.sprintf( method, resource ) );
response.end(); response.end();
} }
} ).listen(8124); } ).listen(8124);
Expand Down

0 comments on commit 7d1d9f0

Please sign in to comment.