Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var nohost = (function(window) {
// The server's filesystem
var Filer = require('filer');
var Path = Filer.Path;
var fs;
// List of FSWatchers for files in the filesystem
var watchers = {};
// Content helpers from the nohost source
var Content = require('content');
// Path and Dir for current nohost url
var nohostPath = document.location.search.substring(1);
var nohostDir = Path.dirname(nohostPath);
// Change a url to a path in the filesystem to a Blob URL
function rewriteURL(url, encoding, callback) {
if(!url || /\:?\/\//.test(url) || /\s*data\:/.test(url)) {
return callback(null, url);
* algorithms necessary for rsync and
* checksum comparison algorithms to check
* the equivalency of two file systems
* as well as general validation functions
*
* Portions used from Node.js Anchor module
* Copyright(c) 2011 Mihai Tomescu
* Copyright(c) 2011 Tolga Tezel
* MIT Licensed
* https://github.com/ttezel/anchor
*/
var MD5 = require('MD5');
var Filer = require('filer');
var Errors = Filer.Errors;
var Path = Filer.Path;
var async = require('../async-lite');
var fsUtils = require('../fs-utils');
// Rsync Options that can be passed are:
// size - the size of each chunk of data in bytes that should be checksumed
// checksum - true: always calculate checksums [default]
// false: ignore checksums for identical files
// recursive - true: sync each contained node in the path provided
// false: only sync the node for the path provided [default]
// time - true: sync modified times of source/destination files
// false: do not change modified times of destination files [default]
// links - true: sync symbolic links as links in destination
// false: sync symbolic links as the files they link to in destination [default]
// versions - true: do not sync a node if the last synced version matches the version it needs to be synced to [default]
// false: sync nodes irrespective of the last synced version
// superficial- true: if a directory path is provided, only sync the directory and not it's contents