We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 993e00f commit c8a4e95Copy full SHA for c8a4e95
HISTORY.md
@@ -1,3 +1,8 @@
1
+unreleased
2
+==========
3
+
4
+ * perf: hoist regular expression
5
6
1.0.1 / 2015-05-04
7
==================
8
index.js
@@ -12,6 +12,12 @@
12
13
module.exports = auth
14
15
+/**
16
+ * RegExp for basic auth user/pass
17
+ */
18
19
+var userPassRegExp = /^([^:]*):(.*)$/
20
21
/**
22
* Parse the Authorization header field of a request.
23
*
@@ -34,7 +40,7 @@ function auth(req) {
34
40
35
41
// credentials
36
42
auth = new Buffer(auth, 'base64').toString();
37
- auth = auth.match(/^([^:]*):(.*)$/);
43
+ auth = auth.match(userPassRegExp)
38
44
if (!auth) return;
39
45
46
return { name: auth[1], pass: auth[2] };
0 commit comments