Skip to content

Instantly share code, notes, and snippets.

@zerebubuth
Created October 24, 2016 16:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zerebubuth/e9e2dc37bcac8fcf94c8a03ba78cbd5a to your computer and use it in GitHub Desktop.
Save zerebubuth/e9e2dc37bcac8fcf94c8a03ba78cbd5a to your computer and use it in GitHub Desktop.
Patch to hack query param support into osm-auth.js
diff --git a/index.js b/index.js
index ebb19f4..c48dff1 100644
--- a/index.js
+++ b/index.js
@@ -169,6 +169,13 @@ module.exports = function(o) {
oauth_token_secret = token('oauth_token_secret');
var url = (options.prefix !== false) ? o.url + options.path : options.path;
+ var url_parts = url.split('?', 2),
+ base_url = url_parts[0];
+
+ if (url_parts.length === 2) {
+ params = xtend(params, ohauth.stringQs(url_parts[1]));
+ }
+
// https://tools.ietf.org/html/rfc5849#section-3.4.1.3.1
if ((!options.options || !options.options.header ||
options.options.header['Content-Type'] === 'application/x-www-form-urlencoded') &&
@@ -180,10 +187,10 @@ module.exports = function(o) {
params.oauth_signature = ohauth.signature(
o.oauth_secret,
oauth_token_secret,
- ohauth.baseString(options.method, url, params));
+ ohauth.baseString(options.method, base_url, params));
return ohauth.xhr(options.method,
- url, params, options.content, options.options, done);
+ base_url, params, options.content, options.options, done);
}
function done(err, xhr) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment