문제

I'm using rack-rewrite in my app to remove trailing slashes if found, but I only want that if not on a certain route.

I've used something like:

use Rack::Rewrite do
  r301 %r{^(?!testroute)(.+)/$}, '$1'
end

To achieve what I need (e.g. all routes but /testroute/ should have any trailing slashes removed). The issue is that even if it hits that specific route, it does not ignore it and it remove the trailing slashes. Is my regex wrong, or is there something that I am not considering?

도움이 되었습니까?

해결책

Try using this instead.

r301 %r{^(?!.*testroute)(.+)/$}, '$1'
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top