fix(core,common): ignore duplicated versions

This commit is contained in:
Micael Levi (lab)
2021-12-02 02:09:48 -04:00
parent ffc0389d7b
commit 68a66757bb
3 changed files with 13 additions and 1 deletions

View File

@@ -164,7 +164,9 @@ export function Controller(
prefixOrOptions.path || defaultPath,
prefixOrOptions.host,
{ scope: prefixOrOptions.scope },
prefixOrOptions.version,
Array.isArray(prefixOrOptions.version)
? Array.from(new Set(prefixOrOptions.version))
: prefixOrOptions.version,
];
return (target: object) => {

View File

@@ -7,6 +7,11 @@ import { VersionValue } from '../../interfaces/version-options.interface';
* @publicApi
*/
export function Version(version: VersionValue): MethodDecorator {
if (Array.isArray(version)) {
// Drop duplicated versions
version = Array.from(new Set(version));
}
return (
target: any,
key: string | symbol,

View File

@@ -136,6 +136,11 @@ export class ApplicationConfig {
}
public enableVersioning(options: VersioningOptions): void {
if (Array.isArray(options.defaultVersion)) {
// Drop duplicated versions
options.defaultVersion = Array.from(new Set(options.defaultVersion));
}
this.versioningOptions = options;
}