Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Reitz Giannattasio committed Jul 20, 2015
2 parents f6d7ae6 + 109f694 commit f612914
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 10 deletions.
2 changes: 1 addition & 1 deletion bower.json
@@ -1 +1 @@
{"name":"push-state-tree","main":"pushStateTree.js","dependencies":{},"version":"0.13.0","description":"A standalone powerful library to manage browser routing with nested level support, complex match expressions and on-fly rules change (convenient to lazy module loading).","repository":{"type":"git","url":"https://github.com/gartz/pushStateTree.git"}}
{"name":"push-state-tree","main":"pushStateTree.js","dependencies":{},"version":"0.13.1","description":"A standalone powerful library to manage browser routing with nested level support, complex match expressions and on-fly rules change (convenient to lazy module loading).","repository":{"type":"git","url":"https://github.com/gartz/pushStateTree.git"}}
2 changes: 1 addition & 1 deletion component.json
@@ -1 +1 @@
{"name":"push-state-tree","description":"A standalone powerful library to manage browser routing with nested level support, complex match expressions and on-fly rules change (convenient to lazy module loading).","version":"0.13.0","keywords":["route","routes","router","pushstate","hashchange","history","location","navigation","controller","MVC","event","events","dispatch","url","SPA","Single Page Application","Lazy Load","apps","app","routing","URI","shim","navigator","navigation"],"main":"push-state-tree.js","development":{"assemble":"~0.4.42","grunt":"~0.4.5","grunt-contrib-clean":"~0.6.0","grunt-contrib-concat":"~0.5.1","grunt-contrib-connect":"~0.10.1","grunt-contrib-jasmine":"~0.9.0","grunt-contrib-jshint":"~0.11.2","grunt-contrib-nodeunit":"~0.4.1","grunt-contrib-qunit":"~0.7.0","grunt-contrib-rename":"0.0.3","grunt-contrib-uglify":"~0.9.1","grunt-contrib-watch":"~0.6.1","grunt-coveralls":"^1.0.0","grunt-json-generator":"~0.1.0","grunt-merge-json":"~0.9.4","grunt-template-jasmine-istanbul":"~0.3.4","grunt-update-json":"~0.2.1","jshint-junit-reporter":"0.2.2","jshint-stylish":"~2.0.1","load-grunt-tasks":"~3.2.0","node-static":"^0.7.7","codeclimate-test-reporter":"0.0.4"}}
{"name":"push-state-tree","description":"A standalone powerful library to manage browser routing with nested level support, complex match expressions and on-fly rules change (convenient to lazy module loading).","version":"0.13.1","keywords":["route","routes","router","pushstate","hashchange","history","location","navigation","controller","MVC","event","events","dispatch","url","SPA","Single Page Application","Lazy Load","apps","app","routing","URI","shim","navigator","navigation"],"main":"push-state-tree.js","development":{"assemble":"~0.4.37","grunt":"~0.4.5","grunt-contrib-clean":"~0.6.0","grunt-contrib-concat":"~0.5.1","grunt-contrib-connect":"~0.10.1","grunt-contrib-jasmine":"~0.8.2","grunt-contrib-jshint":"~0.11.2","grunt-contrib-nodeunit":"~0.4.1","grunt-contrib-qunit":"~0.7.0","grunt-contrib-rename":"0.0.3","grunt-contrib-uglify":"~0.9.1","grunt-contrib-watch":"~0.6.1","grunt-coveralls":"^1.0.0","grunt-json-generator":"~0.1.0","grunt-merge-json":"~0.9.4","grunt-template-jasmine-istanbul":"~0.3.1","grunt-update-json":"~0.2.1","jshint-junit-reporter":"0.3.0","jshint-stylish":"~2.0.0","load-grunt-tasks":"~3.2.0","node-static":"^0.7.6","codeclimate-test-reporter":"0.0.4"}}
2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{
"name": "push-state-tree",
"description": "A standalone powerful library to manage browser routing with nested level support, complex match expressions and on-fly rules change (convenient to lazy module loading).",
"version": "0.13.0",
"version": "0.13.1",
"homepage": "https://github.com/gartz/pushStateTree/",
"author": {
"name": "Gabriel Reitz Giannattasio <gabriel@gartz.com.br>",
Expand Down
7 changes: 4 additions & 3 deletions push-state-tree.js
@@ -1,8 +1,8 @@
//! push-state-tree - v0.13.0 - 2015-07-19
//! push-state-tree - v0.13.1 - 2015-07-19
//* https://github.com/gartz/pushStateTree/
//* Copyright (c) 2015 Gabriel Reitz Giannattasio <gabriel@gartz.com.br>; Licensed

var PushStateTree = {options: {VERSION: '0.13.0'}};
var PushStateTree = {options: {VERSION: '0.13.1'}};
(function (root) {
'use strict';

Expand Down Expand Up @@ -450,7 +450,8 @@ var PushStateTree = {options: {VERSION: '0.13.0'}};
// Remove all begin # chars from the location when using hash
uri = root.location.hash.match(/^(#*)?(.*\/?)/)[2];

if (rootElement.beautifyLocation && rootElement[USE_PUSH_STATE]) {
var usePushState = rootElement[USE_PUSH_STATE];
if (rootElement.beautifyLocation && rootElement.isPathValid && usePushState) {
// when using pushState, replace the browser location to avoid ugly URLs

rootElement.replaceState(
Expand Down
6 changes: 3 additions & 3 deletions push-state-tree.min.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/pushStateTree.js
Expand Up @@ -445,7 +445,8 @@
// Remove all begin # chars from the location when using hash
uri = root.location.hash.match(/^(#*)?(.*\/?)/)[2];

if (rootElement.beautifyLocation && rootElement[USE_PUSH_STATE]) {
var usePushState = rootElement[USE_PUSH_STATE];
if (rootElement.beautifyLocation && rootElement.isPathValid && usePushState) {
// when using pushState, replace the browser location to avoid ugly URLs

rootElement.replaceState(
Expand Down
22 changes: 22 additions & 0 deletions test/specs/route-beutifyLocation.js
Expand Up @@ -88,4 +88,26 @@ describe('PushStateTree beutifyLocation should', function() {
expect(location.pathname).toEqual('/abc');
});

it('not apply beautifyLocation when the basePath is not fulfilled', function(){
history.pushState(null, null, '/invalidBasePath/');
var pst = new PushStateTree({
beautifyLocation: true,
basePath: '/test/'
});
location.hash = '/abc';
expect(pst.uri).toEqual('abc');
expect(location.hash).toEqual('#/abc');
});

it('apply beautifyLocation when the basePath is fulfilled', function(){
history.pushState(null, null, '/test/');
var pst = new PushStateTree({
beautifyLocation: true,
basePath: '/test/'
});
location.hash = '/abc';
expect(pst.uri).toEqual('abc');
expect(location.hash).toEqual('');
});

});

0 comments on commit f612914

Please sign in to comment.