带有嵌套参数的高速路由器不起作用



我有一个匹配所需路由路径的工作示例,但我必须从参数'cameraname'重新创建控制器中的完整文件名,并知道文件名的其余部分。下面的代码是这样工作的:

this.router.get(
`${this.path}/watch/:cameraname([a-zA-Z_]+).m3u8`,
[authMiddleware()],
this.camerasController.getHLSPlaylist,
)

我希望通过添加一个参数来修改它,该参数包含像这样的文件扩展名:

this.router.get(
`${this.path}/watch/:filename(:cameraname([a-zA-Z_]+).m3u8)`,
[authMiddleware()],
this.camerasController.getHLSPlaylist,
)

但这不起作用(没有匹配)。下面是请求路径的一个示例:

/cameras/watch/Garage_Door.m3u8

第一个代码可以工作,但第二个不行。还有更多类似的路线,它们更复杂,参数也更多。这种情况是最简单的。我做错了什么?

express文档没有提到嵌套参数的可能性。

,

this.router.get(
`${this.path}/watch/:cameraname([a-zA-Z_]+).:suffix`,
...)

工作并给您后缀(即文件名的其余部分)作为req.params.suffix

这包括你的要求吗?