Fixed API path generation for multi-segmented model names

no issue

- if a model name has multiple segments, eg `custom-setting` then the URL generated was `/customSettings/` rather than `/custom_settings/`
This commit is contained in:
Kevin Ansfield 2021-09-23 23:52:50 +01:00
parent 7430c28001
commit 23d7aeb764

View File

@ -2,6 +2,7 @@ import AjaxServiceSupport from 'ember-ajax/mixins/ajax-support';
import RESTAdapter from '@ember-data/adapter/rest';
import ghostPaths from 'ghost-admin/utils/ghost-paths';
import {inject as service} from '@ember/service';
import {underscore} from '@ember/string';
export default RESTAdapter.extend(AjaxServiceSupport, {
host: window.location.origin,
@ -24,6 +25,11 @@ export default RESTAdapter.extend(AjaxServiceSupport, {
return this.ajax(this.buildURL(type.modelName, id), 'GET', {data: query});
},
pathForType() {
const type = this._super(...arguments);
return underscore(type);
},
buildURL() {
// Ensure trailing slashes
let url = this._super(...arguments);