Comments (3)
Clout doesn't convert the regular expressions you use in any way, so ^
and $
are not automatically removed, and matching groups are not automatically turned into non-matching groups.
You can see the problem if you take a look at the compiled route:
#clout.core.CompiledRoute{
:source "/foo/:fragment"
:re #"/foo/(^((?!admin).)*$)"
:keys [:fragment]
:absolute? false}
See how your regular expression is inserted directly into the compiled regular expression that Clout produces? In order for your code to work, you need something more like:
(def user-route
(clout/route-compile "/foo/:fragment" {:fragment #"(?:(?!admin).)*"}))
This produces the result you want:
(clout/route-matches user-route (mock/request :get "/foo/user"))
=> {:fragment "user"}
(clout/route-matches user-route (mock/request :get "/foo/admin"))
nil
from clout.
I should have looked at the compiled route... thanks for your help!
from clout.
No problem. It's not something that's immediately obvious, and it's a little bit of a leaky abstraction, because you have to bare in mind that the regular expressions for each keyword are substituted directly into the regular expression in the compiled route.
from clout.
Related Issues (15)
- route-matches Doesn't Match from Servlet Root HOT 2
- Path segment URL decoding causes problems HOT 1
- Routes Throwing 500 in API, fixed after cycling HOT 3
- Missing optional parameters support HOT 3
- Support encoded path components HOT 1
- clout incorrectly excludes ',' from allowed path characters HOT 3
- Upgrade to instaparse 1.3.6 for Clojure 1.7.0 compatibility
- Captured groups in patterns clobber following path parameters HOT 2
- IllegalArgumentException with `:aot :all` and `lein trampoline run` HOT 5
- Old instaparse dependency HOT 4
- Recipe for matching query strings? HOT 6
- [SOLVED] java.lang.IllegalArgumentException: No implementation of method: :route-matches of protocol: #'clout.core/Route found for class: clout.core.CompiledRoute HOT 16
- Clojure 1.3? HOT 3
- + sign in uri path is getting converted to space
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clout.