404

[ Avaa Bypassed ]




Upload:

Command:

botdev@3.149.253.148: ~ $
/**
 * Module dependencies.
 */

var fs = require('fs');
var getUri = require('../');
var assert = require('assert');
var streamToArray = require('stream-to-array');

describe('get-uri', function () {

  describe('"file:" protocol', function () {

    var cache;
    var sep = require('path').sep || '/';

    // TODO: move this out into a more full-featured module some day…
    // i.e. the inverse of https://github.com/TooTallNate/file-path-to-uri
    function path2uri (p) {
      if ('\\' == sep) {
        // windows
        return 'file:///' + p;
      } else {
        // unix
        return 'file://' + p;
      }
    }

    it('should work for local files', function (done) {
      var uri = path2uri(__filename);
      fs.readFile(__filename, 'utf8', function (err, real) {
        if (err) return done(err);
        getUri(uri, function (err, rs) {
          if (err) return done(err);
          cache = rs;
          streamToArray(rs, function (err, array) {
            if (err) return done(err);
            var str = Buffer.concat(array).toString('utf8');
            assert.equal(str, real);
            done();
          });
        });
      });
    });

    it('should return ENOTFOUND for bad filenames', function (done) {
      var uri = path2uri(__filename + 'does-not-exist');
      getUri(uri, function (err, rs) {
        assert(err);
        assert.equal('ENOTFOUND', err.code);
        done();
      });
    });

    it('should return ENOTMODIFIED for the same URI with `cache`', function (done) {
      var uri = path2uri(__filename);
      getUri(uri, { cache: cache }, function (err, rs) {
        assert(err);
        assert.equal('ENOTMODIFIED', err.code);
        done();
      });
    });

  });

});

Filemanager

Name Type Size Permission Actions
data.js File 1.32 KB 0644
file.js File 1.7 KB 0644
ftp.js File 2.38 KB 0644
http.js File 1.86 KB 0644
https.js File 2.1 KB 0644
redirect.js File 2.86 KB 0644
server.crt File 757 B 0644
server.key File 891 B 0644
test.js File 533 B 0644