connect-modrewrite
Advanced tools
Comparing version 0.1.4 to 0.1.5
@@ -42,3 +42,6 @@ module.exports = function(grunt) { | ||
'^/test/\\d*$ /index.html [L]', | ||
'^/test/\\d*/\\d*$ /flag.html [L]' | ||
// Test last flag | ||
'^/test-flag$ /connection [L]', | ||
'^/connection$ /flag.html' | ||
]), | ||
@@ -45,0 +48,0 @@ connect.static(options.base) |
{ | ||
"name": "connect-modrewrite", | ||
"main": "./src/modrewrite.js", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "connect-modrewrite is a middleware for connect. It adds modrewrite functionality to your project", | ||
@@ -6,0 +6,0 @@ "dependencies": { |
@@ -26,4 +26,6 @@ module.exports = function(rules) { | ||
// Rewrite Url | ||
req.url = req.url.replace(rewrite.regex, rewrite.replace); | ||
return rewrite.last; | ||
if(rewrite.regex.test(req.url)) { | ||
req.url = req.url.replace(rewrite.regex, rewrite.replace); | ||
return rewrite.last; | ||
} | ||
@@ -53,4 +55,6 @@ // Else normalize path | ||
// Rewrite Url | ||
req.url = req.url.replace(rewrite.regex, rewrite.replace); | ||
return rewrite.last; | ||
if(rewrite.regex.test(req.url)) { | ||
req.url = req.url.replace(rewrite.regex, rewrite.replace); | ||
return rewrite.last; | ||
} | ||
@@ -57,0 +61,0 @@ } // End of normalization |
@@ -43,17 +43,7 @@ var chai = require( 'chai' ), | ||
it('should be able to recognize Last [L] flag', function(){ | ||
http.get('http://localhost:9001/test/2/1', function(res){ | ||
res.setEncoding('utf8'); | ||
res.on('data', function(chunk){ | ||
expect(chunk).to.be.a('string'); | ||
done(); | ||
}); | ||
it('should be able to recognize Last [L] flag', function(done){ | ||
http.get('http://localhost:9001/test-flag', function(res){ | ||
expect(res.statusCode).to.equal(404); | ||
done(); | ||
}); | ||
http.get('http://localhost:9001/test/2/1', function(res){ | ||
res.setEncoding('utf8'); | ||
res.on('data', function(chunk){ | ||
expect(/flag-is-working/.test(chunk)).to.be.true; | ||
done(); | ||
}); | ||
}); | ||
}) | ||
@@ -60,0 +50,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8880
11
151