Permalink
Browse files

fixed routing of null values and added unit tests to cover it. Also a…

…dded unit tests for distribution files.
  • Loading branch information...
1 parent 9506096 commit 721f11314be9d338aadb021786cffb5826d6d713 @millermedeiros committed Apr 14, 2011
View
@@ -0,0 +1,13 @@
+# Crossroads.js Changelog #
+
+
+## v0.1.1 (2011/04/14) ##
+
+### Fixes ###
+
+ - safe guarded from empty `parse` calls.
+
+
+## v0.1 (2011/04/14) ##
+
+ - initial release with basic features support.
View
@@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
-#Thu Apr 14 02:27:28 BRT 2011
-build.number=10
+#Thu Apr 14 02:58:43 BRT 2011
+build.number=12
@@ -5,7 +5,7 @@ dist.dir = dist
docs.dir = ${dist.dir}/docs
yuicompressor.jar = ${build.dir}/yuicompressor/yuicompressor-2.4.2.jar
product.name = crossroads
-version.number = 0.1
+version.number = 0.1.1
dist.name = ${product.name}.js
dist.amd.name = ${product.name}.amd.js
dist.min.name = ${product.name}.min.js
View
@@ -36,6 +36,7 @@
}
function parse(request){
+ request = request || '';
var route = getMatchedRoute(request),
params = route? getParamValues(request, route) : null;
if(route){
View
@@ -311,6 +311,57 @@ YUI().use('node', 'console', 'test', function (Y){
Y.Assert.areSame('ullamcor', t4);
},
+ testRouteWithEmptyPattern : function(){
+ var t1, t2, t3, t4;
+
+ var a = crossroads.addRoute();
+ a.matched.add(function(foo, bar){
+ t1 = 'lorem';
+ t2 = 'ipsum';
+ });
+
+ crossroads.parse('/123/456');
+ crossroads.parse('/maecennas/ullamcor');
+ crossroads.parse('');
+
+ Y.Assert.areSame('lorem', t1);
+ Y.Assert.areSame('ipsum', t2);
+ },
+
+ testRouteWithEmptyStringPattern : function(){
+ var t1, t2, t3, t4;
+
+ var a = crossroads.addRoute('');
+ a.matched.add(function(foo, bar){
+ t1 = 'lorem';
+ t2 = 'ipsum';
+ });
+
+ crossroads.parse('/123/456');
+ crossroads.parse('/maecennas/ullamcor');
+ crossroads.parse('');
+
+ Y.Assert.areSame('lorem', t1);
+ Y.Assert.areSame('ipsum', t2);
+ },
+
+ testRouteWithEmptyParse : function(){
+ var t1, t2, t3, t4;
+
+ var a = crossroads.addRoute('');
+ a.matched.add(function(foo, bar){
+ t1 = 'lorem';
+ t2 = 'ipsum';
+ });
+
+ crossroads.parse('/123/456');
+ crossroads.parse('/maecennas/ullamcor');
+ crossroads.parse();
+
+ Y.Assert.areSame('lorem', t1);
+ Y.Assert.areSame('ipsum', t2);
+ },
+
//-------------------------- Param Validation ---------------------------------------//
testRouteWithRegexRules : function(){
View
@@ -0,0 +1,18 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
+ <head>
+ <meta http-equiv="content-type" content="application/xhtml+xml;charset=utf-8" />
+ <meta http-equiv="content-style-type" content="text/css" />
+ <title>DEV | unit test</title>
+ <link type="text/css" rel="stylesheet" href="http://yui.yahooapis.com/3.2.0/build/cssfonts/fonts-min.css" />
+ </head>
+ <body>
+ <div id="wrapper">
+ <div id="testLogger" class="yui3-skin-sam"></div>
+ </div>
+ <script type="text/javascript" src="http://yui.yahooapis.com/3.2.0/build/yui/yui-min.js"></script>
+ <script type="text/javascript" src="../../dev/lib/js-signals.js"></script>
+ <script type="text/javascript" src="../../dist/crossroads.js"></script>
+ <script type="text/javascript" src="./unit-01.js"></script>
+ </body>
+</html>
@@ -0,0 +1,18 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
+ <head>
+ <meta http-equiv="content-type" content="application/xhtml+xml;charset=utf-8" />
+ <meta http-equiv="content-style-type" content="text/css" />
+ <title>DEV | unit test</title>
+ <link type="text/css" rel="stylesheet" href="http://yui.yahooapis.com/3.2.0/build/cssfonts/fonts-min.css" />
+ </head>
+ <body>
+ <div id="wrapper">
+ <div id="testLogger" class="yui3-skin-sam"></div>
+ </div>
+ <script type="text/javascript" src="http://yui.yahooapis.com/3.2.0/build/yui/yui-min.js"></script>
+ <script type="text/javascript" src="../../dev/lib/js-signals.js"></script>
+ <script type="text/javascript" src="../../dist/crossroads.min.js"></script>
+ <script type="text/javascript" src="./unit-01.js"></script>
+ </body>
+</html>
View
@@ -2,8 +2,8 @@
* Crossroads - JavaScript Routes
* Released under the MIT license <http://www.opensource.org/licenses/mit-license.php>
* @author Miller Medeiros
- * @version 0.1
- * @build 9 (04/14/2011 02:27 AM)
+ * @version 0.1.1
+ * @build 11 (04/14/2011 02:58 AM)
*/
define(function(){
@@ -64,6 +64,7 @@ define(function(){
}
function parse(request){
+ request = request || '';
var route = getMatchedRoute(request),
params = route? getParamValues(request, route) : null;
if(route){
View
@@ -2,8 +2,8 @@
* Crossroads - JavaScript Routes
* Released under the MIT license <http://www.opensource.org/licenses/mit-license.php>
* @author Miller Medeiros
- * @version 0.1
- * @build 9 (04/14/2011 02:27 AM)
+ * @version 0.1.1
+ * @build 11 (04/14/2011 02:58 AM)
*/
(function(global){
@@ -64,6 +64,7 @@
}
function parse(request){
+ request = request || '';
var route = getMatchedRoute(request),
params = route? getParamValues(request, route) : null;
if(route){
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit 721f113

Please sign in to comment.