mirror of
https://github.com/nestjs/nest.git
synced 2026-02-21 23:11:44 +00:00
fix(core,common): ignore duplicated versions
This commit is contained in:
@@ -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) => {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user