瀏覽代碼

run eslint on simplehttpserver

Gero3 6 年之前
父節點
當前提交
4c91e53687
共有 1 個文件被更改,包括 16 次插入14 次删除
  1. 16 14
      utils/servers/simplehttpserver.js

+ 16 - 14
utils/servers/simplehttpserver.js

@@ -30,7 +30,7 @@ var port = 8000,
 		"mp4": "video/mp4",
 		"mp4": "video/mp4",
 		"txt": "text/plain",
 		"txt": "text/plain",
 		"bin": "application/octet-stream"
 		"bin": "application/octet-stream"
-  };
+	};
 
 
 // https://github.com/parshap/node-sanitize-filename/blob/master/index.js#L33-L47
 // https://github.com/parshap/node-sanitize-filename/blob/master/index.js#L33-L47
 var illegalRe = /[\?<>:\*\|":]/g;
 var illegalRe = /[\?<>:\*\|":]/g;
@@ -39,15 +39,17 @@ var reservedRe = /^\.+$/;
 var windowsReservedRe = /^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\..*)?$/i;
 var windowsReservedRe = /^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\..*)?$/i;
 var windowsTrailingRe = /[\. ]+$/;
 var windowsTrailingRe = /[\. ]+$/;
 
 
-function sanitize(input) {
-  var sanitized = input
-	.replace(/\//g, "\\")
-	.replace(illegalRe, "")
-	.replace(controlRe, "")
-	.replace(reservedRe, "")
-	.replace(windowsReservedRe, "")
-	.replace(windowsTrailingRe, "");
-  return sanitized;
+function sanitize( input ) {
+
+	var sanitized = input
+		.replace( /\//g, "\\" )
+		.replace( illegalRe, "" )
+		.replace( controlRe, "" )
+		.replace( reservedRe, "" )
+		.replace( windowsReservedRe, "" )
+		.replace( windowsTrailingRe, "" );
+	return sanitized;
+
 }
 }
 
 
 
 
@@ -56,8 +58,8 @@ port = process.argv[ 2 ] ? parseInt( process.argv[ 2 ], 0 ) : port;
 
 
 function handleRequest( request, response ) {
 function handleRequest( request, response ) {
 
 
-  var urlObject = urlParser.parse( request.url, true );
-  var pathname = decodeURIComponent( sanitize( urlObject.pathname ) );
+	var urlObject = urlParser.parse( request.url, true );
+	var pathname = decodeURIComponent( sanitize( urlObject.pathname ) );
 
 
 	console.log( '[' + ( new Date() ).toUTCString() + '] ' + '"' + request.method + ' ' + pathname + '"' );
 	console.log( '[' + ( new Date() ).toUTCString() + '] ' + '"' + request.method + ' ' + pathname + '"' );
 
 
@@ -119,7 +121,7 @@ function handleRequest( request, response ) {
 				files.forEach( function ( item ) {
 				files.forEach( function ( item ) {
 
 
 				  var urlpath = path.join( pathname, item ),
 				  var urlpath = path.join( pathname, item ),
-					itemStats = fs.statSync( path.join( currentDir, urlpath ) );
+						itemStats = fs.statSync( path.join( currentDir, urlpath ) );
 
 
 					if ( itemStats.isDirectory() ) {
 					if ( itemStats.isDirectory() ) {
 
 
@@ -144,7 +146,7 @@ function handleRequest( request, response ) {
 
 
 http.createServer( handleRequest ).listen( port );
 http.createServer( handleRequest ).listen( port );
 
 
-require( 'dns' ).lookup( require( 'os' ).hostname(), function ( err, addr, fam ) {
+require( 'dns' ).lookup( require( 'os' ).hostname(), function ( err, addr ) {
 
 
  	console.log( 'Running at http://' + addr + ( ( port === 80 ) ? '' : ':' ) + port + '/' );
  	console.log( 'Running at http://' + addr + ( ( port === 80 ) ? '' : ':' ) + port + '/' );