Begin work on offline vault client tests

This commit is contained in:
wltsmrz
2014-05-29 14:33:53 -07:00
parent 61bc01ae12
commit 9a349a3d55
2 changed files with 157 additions and 105 deletions

View File

@@ -1,4 +1,4 @@
var request = require('superagent');
var superagent = require('superagent');
function RippleTxt() {
this.txts = { };
@@ -13,6 +13,14 @@ RippleTxt.urlTemplates = [
'http://{{domain}}/ripple.txt'
];
RippleTxt.request = function() {
return request;
};
RippleTxt.prototype.request = function(url, callback) {
return superagent.get(url, callback);
};
/**
* Gets the ripple.txt file for the given domain
*
@@ -36,7 +44,7 @@ RippleTxt.prototype.get = function(domain, fn) {
url = url.replace('{{domain}}', domain);
request.get(url, function(err, resp) {
self.request(url, function(err, resp) {
if (err || !resp.text) {
return nextUrl(++i);
}
@@ -67,7 +75,7 @@ RippleTxt.prototype.parse = function(txt) {
continue;
}
if (line[0] === '[' && line[line.length-1] === ']') {
if (line[0] === '[' && line[line.length - 1] === ']') {
currentSection = line.slice(1, line.length - 1);
sections[currentSection] = [];
} else {