Ensure URL used for oauth header is absolute

Fixes #356.
This commit is contained in:
John Firebaugh 2013-07-20 18:40:41 -07:00 committed by Tom Hughes
parent c71209507b
commit 606e66beb3

View file

@ -1,6 +1,12 @@
//= require ohauth
$(document).ready(function () {
function makeAbsolute(url) {
var a = document.createElement('a');
a.href = url;
return a.href;
}
if (OSM.oauth_token) {
var headerGenerator = window.ohauth.headerGenerator({
consumer_key: OSM.oauth_consumer_key,
@ -12,7 +18,7 @@ $(document).ready(function () {
$.ajaxPrefilter(function(options, jqxhr) {
if (options.oauth) {
options.headers = options.headers || {};
options.headers.Authorization = headerGenerator(options.type, options.url, jqxhr.data);
options.headers.Authorization = headerGenerator(options.type, makeAbsolute(options.url), jqxhr.data);
}
});
}