egg-router icon indicating copy to clipboard operation
egg-router copied to clipboard

fix: remove override url()

Open atian25 opened this issue 6 years ago • 4 comments

  • close https://github.com/eggjs/egg/issues/3915
  • 这段逻辑似乎是没必要的,而且实现的不严谨,内置就有了 https://github.com/eggjs/egg-router/blob/master/lib/layer.js#L112

atian25 avatar Aug 30 '19 09:08 atian25

Codecov Report

Merging #6 into master will decrease coverage by 0.05%. The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master       #6      +/-   ##
==========================================
- Coverage   99.41%   99.35%   -0.06%     
==========================================
  Files           5        5              
  Lines         342      311      -31     
==========================================
- Hits          340      309      -31     
  Misses          2        2
Impacted Files Coverage Δ
lib/egg_router.js 96.96% <ø> (-0.97%) :arrow_down:
lib/router.js 100% <ø> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 512808f...ec4f20e. Read the comment docs.

codecov[bot] avatar Aug 30 '19 09:08 codecov[bot]

array 的那个,看来要特殊处理下

atian25 avatar Aug 30 '19 09:08 atian25

测试用例也需要修复。

fengmk2 avatar Aug 30 '19 12:08 fengmk2

发现内置的方法跟我们的实现有所不同:

  • 我们会把 params 里面剩余的没有匹配的,当做 query 拼接;内置的需要显示指定第二个参数
  • 我们会无视不匹配的值,如 /:id 没有 params.id 时,会保留;内置的会抛错。
  • router name 不存在时,我们会返回空字符串;内置会返回一个 Error 对象(非抛错)。

第一点可以支持,第 2 点,我感觉我们之前的是不是不太合理?第 3 点两者都不对,应该抛错。

后面 2 个要不要改还是保留我们的实现?该视为 bug 还是 break?

@fengmk2

atian25 avatar Aug 31 '19 14:08 atian25