Skip to content

Commit

Permalink
page.js 1.4.0 support
Browse files Browse the repository at this point in the history
  • Loading branch information
kethinov committed Nov 12, 2014
1 parent e919930 commit b7ba780
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "page.js-body-parser.js",
"description": "Plugin for page.js which implements support for forms akin to body-parser.",
"author": "Eric Newport <[email protected]>",
"version": "1.0.2",
"version": "1.0.3",
"homepage": "https://github.com/kethinov/page.js-body-parser.js",
"license": "Creative Commons Attribution 4.0 International License",
"main": "page.js-body-parser.js",
Expand Down
11 changes: 2 additions & 9 deletions page.js-body-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
if (form.pathname === location.pathname && (form.hash || '#' === link)) return;

// x-origin
if (!sameOrigin(form.action)) return;
if (!page.sameOrigin(form.action)) return;

// rebuild path
path = form.pathname + form.search + (form.hash || '');
Expand Down Expand Up @@ -126,17 +126,10 @@
var ctx = new page.Context(path, state);
if (state && state.body) ctx.body = state.body;
if (false !== dispatch) page.dispatch(ctx);
if (!ctx.unhandled) ctx.pushState();
if (false !== ctx.handled) ctx.pushState();
return ctx;
};

// needed because https://github.com/visionmedia/page.js/issues/125
function sameOrigin(href) {
var origin = location.protocol + '//' + location.hostname;
if (location.port) origin += ':' + location.port;
return (href && (0 == href.indexOf(origin)));
}

// expose pageBodyParser
if ('undefined' == typeof module) {
window.pageBodyParser = pageBodyParser;
Expand Down
2 changes: 1 addition & 1 deletion sampleApp.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
make sure to run:
bower install page.js
-->
<script src='bower_components/page.js/index.js'></script>
<script src='bower_components/page.js/page.js'></script>

<!--
load body-parser plugin
Expand Down

0 comments on commit b7ba780

Please sign in to comment.