Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mock-Server的路径匹配问题 #3356

Closed
lclancey opened this issue Aug 3, 2020 · 0 comments
Closed

Mock-Server的路径匹配问题 #3356

lclancey opened this issue Aug 3, 2020 · 0 comments

Comments

@lclancey
Copy link

lclancey commented Aug 3, 2020

Bug report(问题描述)

Mock-Server在处理请求过来的路由时, responseFake中使用的正则表达式,会优先匹配较短的路径, 使得长路径无法进入, 全部被短路径拦截

url: new RegExp(`${process.env.VUE_APP_BASE_API}${*url*}`),

Steps to reproduce(问题复现步骤)

  1. API和mock-server中假如已经有如下两个路径互相对应(请求方法相同,路径互相包含)
[
  {type:'get',url:'/v1/weath'},
  {type:'get',url:'/v1/weather'},
]
  1. 使用长路径/v1/weather/realtime对应的API请求, 返回的数据却是短路径/v1/weath的Mock数据

Screenshot or Gif(截图或动态图)

mock中两条路径

mock-1

请求长路径, 返回短路径

mock-2

Link to minimal reproduction(最小可在线还原demo)

Other relevant information(格外信息)

目前的这种正则匹配, 甚至会把诸如/v1/weahter/realtime /v1/weather/forecast等路径全部拦截, 这个问题的原因和解决方法在#2385 这里就有, 我这里算是重复提交

我以为这是个实际使用中很容易被发现的问题,但那个issue没有人回复和处理, 鉴于我主要工作是嵌入式C,前端只是业余了解,所以不确定是不是说API不能这样设计, 所以不会碰到这情况?

@lclancey lclancey closed this as completed Dec 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant