diff --git a/index.js b/index.js index 1a77c6f..ccad386 100644 --- a/index.js +++ b/index.js @@ -51,6 +51,8 @@ function request(options, callback) { if(!options.uri && options.uri !== "") throw new Error("options.uri is a required argument"); + if(typeof options.uri === "object") + options.uri = options.uri.href; if(typeof options.uri != "string") throw new Error("options.uri must be a string"); diff --git a/test.js b/test.js index f427f23..8643b4d 100644 --- a/test.js +++ b/test.js @@ -1,6 +1,7 @@ var test = require('tape') var request = require('./') +var urlParser = require('url') test('try a CORS GET', function (t) { var url = 'https://www.googleapis.com/plus/v1/activities' @@ -18,3 +19,11 @@ test('json true', function (t) { t.end() }) }) + +test('parsed url', function (t) { + var url = urlParser.parse('https://www.googleapis.com/plus/v1/activities') + request({url: url, json: true}, function(err, resp, body) { + t.equal(body.error.code, 400) + t.end() + }) +})