Commit 2fc62cba authored by Matthew Taylor's avatar Matthew Taylor Committed by GitHub

Merge pull request #830 from mewtaylor/hotfix/gh-828

[Develop] Fix GH-828: check street number range for address
parents 47d0cca8 4d9fe86f
var defaults = require('lodash.defaults'); var defaults = require('lodash.defaults');
var defaultsDeep = require('lodash.defaultsdeep');
var xhr = require('xhr'); var xhr = require('xhr');
var jar = require('./jar'); var jar = require('./jar');
...@@ -15,17 +16,15 @@ var urlParams = require('./url-params'); ...@@ -15,17 +16,15 @@ var urlParams = require('./url-params');
*/ */
module.exports = function (opts, callback) { module.exports = function (opts, callback) {
defaults(opts, { defaultsDeep(opts, {
host: process.env.API_HOST, host: process.env.API_HOST,
headers: {}, headers: {
'X-Requested-With': 'XMLHttpRequest'
},
responseType: 'json', responseType: 'json',
useCsrf: false useCsrf: false
}); });
defaults(opts.headers, {
'X-Requested-With': 'XMLHttpRequest'
});
opts.uri = opts.host + opts.uri; opts.uri = opts.host + opts.uri;
if (opts.params) { if (opts.params) {
...@@ -43,7 +42,9 @@ module.exports = function (opts, callback) { ...@@ -43,7 +42,9 @@ module.exports = function (opts, callback) {
// For IE < 10, we must use XDR for cross-domain requests. XDR does not support // For IE < 10, we must use XDR for cross-domain requests. XDR does not support
// custom headers. // custom headers.
defaults(opts, {useXDR: true}); defaults(opts, {useXDR: true});
delete opts.headers; if (opts.useXDR) {
delete opts.headers;
}
if (opts.authentication) { if (opts.authentication) {
var authenticationParams = ['x-token=' + opts.authentication]; var authenticationParams = ['x-token=' + opts.authentication];
var parts = opts.uri.split('?'); var parts = opts.uri.split('?');
......
...@@ -8,7 +8,11 @@ module.exports = function smartyStreetApi (params, callback) { ...@@ -8,7 +8,11 @@ module.exports = function smartyStreetApi (params, callback) {
api({ api({
host: 'https://api.smartystreets.com', host: 'https://api.smartystreets.com',
uri: '/street-address', uri: '/street-address',
params: params headers: {
'X-Standardize-Only': true
},
params: params,
useXDR: false
}, function (err, body, res) { }, function (err, body, res) {
if (err) return callback(err); if (err) return callback(err);
if (res.statusCode !== 200) { if (res.statusCode !== 200) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment