Permalink
Browse files

Merge branch 'master' into vnext

  • Loading branch information...
ibdknox committed Aug 11, 2011
2 parents 584a032 + f0e2062 commit 4f361f81802ce853a1a4d808ebff5337f1db836e
Showing with 30 additions and 8 deletions.
  1. +3 −1 README.md
  2. +2 −5 src/noir/util/middleware.clj
  3. +1 −1 src/noir/validation.clj
  4. +24 −1 test/noir/test/core.clj
View
@@ -2,7 +2,7 @@
A framework for writing clojure websites. Noir is currently being used in production at http://www.typewire.io
-Learn more at [Web Noir](http://www.webnoir.org)
+Learn more at [Web Noir](http://www.webnoir.org) and see [Pinot](https://github.com/ibdknox/pinot) for its ClojureScript counterpart.
## Usage
@@ -20,6 +20,8 @@ If you want to include Noir in an already created leiningen project, simply add
[noir "1.1.0"]
```
+You can also use [noir-cljs](https://github.com/ibdknox/noir-cljs) to add ClojureScript compilation to Noir via middleware.
+
## Docs
* [Web Noir](http://www.webnoir.org)
@@ -6,8 +6,5 @@
to display all utf-8 characters."
[handler]
(fn [request]
- (let [resp (handler request)
- ct (get-in resp [:headers "Content-Type"])
- neue-ct (str ct "; charset=utf-8")]
- (assoc-in resp [:headers "Content-Type"] neue-ct))))
-
+ (let [resp (handler request)]
+ (update-in resp [:headers "Content-Type"] str "; charset=utf-8"))))
View
@@ -37,7 +37,7 @@
(defn is-email?
"Returns true if v is an email address"
[v]
- (re-matches #"(?i)\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b" v))
+ (re-matches #"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?" v))
(declare ^:dynamic *errors*)
View
@@ -8,7 +8,8 @@
[noir.session :as session]
[noir.options :as options]
[noir.response :as resp]
- [noir.cookies :as cookies]))
+ [noir.cookies :as cookies]
+ [noir.validation :as vali]))
(deftest hashing
(let [pass (crypt/encrypt "password")]
@@ -82,3 +83,25 @@
(has-content-type "text/html; charset=utf-8")
(has-body "ąčęė")))
+(deftest valid-emails
+ (are [email] (vali/is-email? email)
+ "testword@domain.com"
+ "test+word@domain.com"
+ "test_word@domain.com"
+ "test'word@domain.com"
+ "test`word@domain.com"
+ "test#word@domain.com"
+ "test=word@domain.com"
+ "test|word@domain.com"
+ "testword@test.domain.com"
+ "te$t@test.com"
+ "t`e's.t&w%o#r{d@t.e.s.t"
+ "x@x.xx"))
+
+(deftest invalid-emails
+ (are [email] (not (vali/is-email? email))
+ ".test@domain.com"
+ "-@-.com"
+ "test"
+ "test.@domain.com"
+ "test@com"))

0 comments on commit 4f361f8

Please sign in to comment.