2014-10-30 21:44:22 +01:00
|
|
|
import DS from "ember-data";
|
2015-08-23 18:56:41 +02:00
|
|
|
import Ember from "ember";
|
2014-10-30 21:44:22 +01:00
|
|
|
|
2014-07-06 17:37:54 +02:00
|
|
|
export default DS.RESTAdapter.extend({
|
2015-08-23 18:56:41 +02:00
|
|
|
// set PROOF_KEY_KNOWLEDGE header
|
|
|
|
headers: Ember.computed('encryption.hash', function() {
|
|
|
|
return {
|
|
|
|
"X-Croodle-Proof-Key-Knowledge": this.get('encryption.hash')
|
|
|
|
};
|
|
|
|
}),
|
|
|
|
|
2014-07-06 19:22:38 +02:00
|
|
|
// set namespace to api.php in same subdirectory
|
|
|
|
namespace:
|
|
|
|
window.location.pathname
|
|
|
|
// remove index.html if it's there
|
|
|
|
.replace(/index.html$/, '')
|
2015-01-24 18:32:31 +01:00
|
|
|
// remove tests prefix which is added by testem (starting with a number)
|
2015-01-24 16:51:26 +01:00
|
|
|
.replace(/\/\d+\/tests/, '')
|
2015-01-24 18:32:31 +01:00
|
|
|
// remove tests prefix which is added by tests run in browser
|
|
|
|
.replace(/tests/, '')
|
2014-07-06 19:22:38 +02:00
|
|
|
// remove leading and trailing slash
|
|
|
|
.replace(/\/$/, '')
|
|
|
|
// add api.php
|
2015-08-01 18:42:48 +02:00
|
|
|
.concat('/api/index.php')
|
2014-07-06 19:22:38 +02:00
|
|
|
// remove leading slash
|
|
|
|
.replace(/^\//g, '')
|
2014-07-06 17:37:54 +02:00
|
|
|
});
|