mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
deprecate the use of /api in the rest nameSpace
This commit is contained in:
@@ -54,6 +54,13 @@ import(environmentFilePath)
|
||||
function generateEnvironmentFile(file: GlobalConfig): void {
|
||||
file.production = production;
|
||||
buildBaseUrls(file);
|
||||
|
||||
// TODO remove workaround in beta 5
|
||||
if (file.rest.nameSpace.match("(.*)/api/?$") !== null) {
|
||||
const newValue = getNameSpace(file.rest.nameSpace);
|
||||
console.log(colors.white.bgMagenta.bold(`The rest.nameSpace property in your environment file or in your DSPACE_REST_NAMESPACE environment variable ends with '/api'.\nThis is deprecated. As '/api' isn't configurable on the rest side, it shouldn't be repeated in every environment file.\nPlease change the rest nameSpace to '${newValue}'`));
|
||||
}
|
||||
|
||||
const contents = `export const environment = ` + JSON.stringify(file);
|
||||
writeFile(targetPath, contents, (err) => {
|
||||
if (err) {
|
||||
@@ -112,5 +119,16 @@ function getPort(port: number): string {
|
||||
}
|
||||
|
||||
function getNameSpace(nameSpace: string): string {
|
||||
// TODO remove workaround in beta 5
|
||||
const apiMatches = nameSpace.match("(.*)/api/?$");
|
||||
if (apiMatches != null) {
|
||||
let newValue = '/'
|
||||
if (hasValue(apiMatches[1])) {
|
||||
newValue = apiMatches[1];
|
||||
}
|
||||
return newValue;
|
||||
}
|
||||
else {
|
||||
return nameSpace ? nameSpace.charAt(0) === '/' ? nameSpace : '/' + nameSpace : '';
|
||||
}
|
||||
}
|
||||
|
@@ -61,7 +61,7 @@ describe('HALEndpointService', () => {
|
||||
describe('getRootEndpointMap', () => {
|
||||
it('should configure a new EndpointMapRequest', () => {
|
||||
(service as any).getRootEndpointMap();
|
||||
const expected = new EndpointMapRequest(requestService.generateRequestId(), environment.rest.baseUrl);
|
||||
const expected = new EndpointMapRequest(requestService.generateRequestId(), environment.rest.baseUrl + '/api');
|
||||
expect(requestService.configure).toHaveBeenCalledWith(expected);
|
||||
});
|
||||
|
||||
|
@@ -16,7 +16,7 @@ export class HALEndpointService {
|
||||
}
|
||||
|
||||
protected getRootHref(): string {
|
||||
return new RESTURLCombiner('/').toString();
|
||||
return new RESTURLCombiner('/api').toString();
|
||||
}
|
||||
|
||||
protected getRootEndpointMap(): Observable<EndpointMap> {
|
||||
|
Reference in New Issue
Block a user