|
100 | 100 | query[key] = this._options.query[key]; |
101 | 101 | } |
102 | 102 |
|
103 | | - var sessionToken; |
104 | | - |
105 | | - if (this._http.getSessionToken) { |
106 | | - sessionToken = this._http.getSessionToken(); |
107 | | - } else if (this._cookies.S) { |
108 | | - sessionToken = this._cookies.S; |
109 | | - } |
110 | | - |
111 | | - if (sessionToken) { |
112 | | - query.session_token = sessionToken; |
113 | | - } |
114 | | - |
115 | 103 | var queryParts = []; |
116 | 104 | for (var i in query) { |
117 | 105 | if (!query.hasOwnProperty(i)) continue; |
|
348 | 336 | 'use strict'; |
349 | 337 |
|
350 | 338 | var context = typeof exports !== 'undefined' ? exports : window; |
351 | | - var SESSION_COOKIE_NAME_REGEX = /(?:^| )S=/; |
352 | 339 |
|
353 | | - AngularAdapter.$inject = ['$http', '$document', '$window']; |
354 | | - function AngularAdapter($http, $document, $window) { |
| 340 | + AngularAdapter.$inject = ['$http', '$window']; |
| 341 | + function AngularAdapter($http, $window) { |
355 | 342 | this._$http = $http; |
356 | | - this._$document = $document; |
357 | 343 | this._$window = $window; |
358 | 344 | } |
359 | 345 |
|
|
370 | 356 | }).then(formatResponse); |
371 | 357 | }; |
372 | 358 |
|
373 | | - AngularAdapter.prototype.getSessionToken = function() { |
374 | | - var cookie = this._$document[0].cookie; |
375 | | - |
376 | | - // Note: Read from the cookie directly to ensure that it isn't outdated. |
377 | | - if (!cookie.length) { |
378 | | - return null; |
379 | | - } |
380 | | - |
381 | | - var found = cookie.match(SESSION_COOKIE_NAME_REGEX); |
382 | | - |
383 | | - if (!found) { |
384 | | - return null; |
385 | | - } |
386 | | - |
387 | | - var start = found.index; |
388 | | - |
389 | | - if (-1 == start) { |
390 | | - return null; |
391 | | - } |
392 | | - |
393 | | - start += 2; |
394 | | - |
395 | | - // Regex includes leading space, so account for it. |
396 | | - if (found[0].charAt(0) === ' ') { |
397 | | - start++; |
398 | | - } |
399 | | - |
400 | | - var end = cookie.indexOf(";", start); |
401 | | - |
402 | | - if (-1 == end) { |
403 | | - end = cookie.length; |
404 | | - } |
405 | | - |
406 | | - return unescape(cookie.substring(start, end)); |
407 | | - }; |
408 | | - |
409 | 359 | var transformResponse = function(data) { |
410 | 360 | // Do not deserialize the data -- let API client do that. |
411 | 361 | // Just return the raw response body. |
|
446 | 396 | // and the same instance will be passed around through the Angular app. |
447 | 397 | module.factory('taggedApi', taggedApiFactory); |
448 | 398 |
|
449 | | - taggedApiFactory.$inject = ['$http', '$q']; |
450 | | - function taggedApiFactory($http, $q) { |
451 | | - var angularAdapter = new TaggedApi.AngularAdapter($http); |
| 399 | + taggedApiFactory.$inject = ['$http', '$q', '$window']; |
| 400 | + function taggedApiFactory($http, $q, $window) { |
| 401 | + var angularAdapter = new TaggedApi.AngularAdapter($http, $window); |
452 | 402 |
|
453 | 403 | var api = new TaggedApi('/api/', { |
454 | 404 | query: { |
|
0 commit comments