decide.nolog.cz/app/adapters/application.js
2023-10-15 20:37:03 +02:00

22 lines
726 B
JavaScript

import RESTAdapter from '@ember-data/adapter/rest';
import { inject as service } from '@ember/service';
export default class ApplicationAdapter extends RESTAdapter {
@service
encryption;
// set namespace to api.php in same subdirectory
namespace = window.location.pathname
// remove index.html if it's there
.replace(/index.html$/, '')
// remove tests prefix which is added by testem (starting with a number)
.replace(/\/\d+\/tests/, '')
// remove tests prefix which is added by tests run in browser
.replace(/tests/, '')
// remove leading and trailing slash
.replace(/\/$/, '')
// add api.php
.concat('/api/index.php')
// remove leading slash
.replace(/^\//g, '');
}