我有通过id获取用户的路径:
/user/{id}
然后我将其转换为regexp:
pathToRegexp(path.replace(/\{/g, ':').replace(/\}/g, ''))
然后将其与
const matchedPaths = this.map.filter((obj: mapper) =>
requestUrl.match(obj.regexp)
)[0]
但当我转到/user/count
时,它会认为我要转到/user/{id}
。
https://stackoverflow.com/questions/56241005
复制相似问题