Comparing version 0.0.2 to 0.0.3
@@ -420,5 +420,3 @@ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
var Response = require("./response"); | ||
var _u = require("./utils"); | ||
var pathToRegexp = require('path-to-regexp'); | ||
@@ -435,2 +433,3 @@ | ||
var locals = {}; | ||
var started = false; | ||
var app = { | ||
@@ -486,3 +485,3 @@ get: function () { | ||
var prop = route.k[i - 1].name; | ||
var val = _u.DecodeParam(m[i]); | ||
var val = _u.decodeParam(m[i]); | ||
@@ -518,3 +517,3 @@ if (!!val || !(_u.hasOwnProperty.call(params, prop))) { | ||
} else { | ||
fragment = this.getHash(); | ||
fragment = _u.getHash(); | ||
} | ||
@@ -524,16 +523,5 @@ } | ||
}, | ||
getHash: function (target) { | ||
var match = (target || window).location.href.match(/#(.*)$/); | ||
return match ? match[1] : ''; | ||
}, | ||
getSearch: function () { | ||
var match = location.href.replace(/#.*/, '').match(/\?.+/); | ||
return match ? match[0] : ''; | ||
}, | ||
decodeFragment: function (fragment) { | ||
return decodeURI(fragment.replace(/%25/g, '%2525')); | ||
}, | ||
getPath: function () { | ||
var path = this.decodeFragment( | ||
location.pathname + this.getSearch() | ||
var path = _u.decodeFragment( | ||
location.pathname + _u.getSearch() | ||
).slice(this.root.length - 1); | ||
@@ -544,3 +532,3 @@ return path.charAt(0) === '/' ? path.slice(1) : path; | ||
var path = location.pathname.replace(/[^\/]$/, '$&/'); | ||
return path === this.root && !this.getSearch(); | ||
return path === this.root && !_u.getSearch(); | ||
}, | ||
@@ -551,3 +539,3 @@ checkUrl: function (e) { | ||
if (current === this.fragment && this.iframe) { | ||
current = this.getHash(this.iframe.contentWindow); | ||
current = _u.getHash(this.iframe.contentWindow); | ||
} | ||
@@ -565,3 +553,3 @@ | ||
matchRoot: function () { | ||
var path = this.decodeFragment(location.pathname); | ||
var path = _u.decodeFragment(location.pathname); | ||
var rootPath = path.slice(0, this.root.length - 1) + '/'; | ||
@@ -571,4 +559,4 @@ return rootPath === this.root; | ||
start: function (options) { | ||
if (History.started) throw new Error('Backbone.history has already been started'); | ||
History.started = true; | ||
if (started) throw new Error('history has already been started'); | ||
started = true; | ||
@@ -593,3 +581,3 @@ this.options = _opts; | ||
} else if (this._hasPushState && this.atRoot()) { | ||
this.catch(this.getHash()); | ||
this.catch(_u.getHash()); | ||
} | ||
@@ -641,7 +629,7 @@ } | ||
if (this._checkUrlInterval) clearInterval(this._checkUrlInterval); | ||
History.started = false; | ||
started = false; | ||
}, | ||
listen: function (next) { | ||
(!!next ? next : _u.nothing)(); | ||
this.start(_opts); | ||
(!!next ? next : _u.nothing)(); | ||
}, | ||
@@ -662,3 +650,3 @@ locals: locals | ||
*/ | ||
DecodeParam: function (val) { | ||
decodeParam: function (val) { | ||
if (typeof val !== 'string' || val.length === 0) { | ||
@@ -680,4 +668,15 @@ return val; | ||
nothing: function () { | ||
}, | ||
getHash: function (target) { | ||
var match = (target || window).location.href.match(/#(.*)$/); | ||
return match ? match[1] : ''; | ||
}, | ||
decodeFragment: function (fragment) { | ||
return decodeURI(fragment.replace(/%25/g, '%2525')); | ||
}, | ||
getSearch: function () { | ||
var match = location.href.replace(/#.*/, '').match(/\?.+/); | ||
return match ? match[0] : ''; | ||
} | ||
}; | ||
},{}]},{},[5]); |
@@ -5,6 +5,7 @@ { | ||
"private": false, | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"author": "eray <relfishere@gmail.com>", | ||
"scripts": { | ||
"build": "browserify src/rylai.js -o build/rylai.js" | ||
"build": "browserify src/rylai.js -o build/rylai.js", | ||
"pushState": "node pushState.js" | ||
}, | ||
@@ -11,0 +12,0 @@ "dependencies": { |
@@ -0,1 +1,5 @@ | ||
/** | ||
* @pushState | ||
*/ | ||
var express = require('express'); | ||
@@ -7,3 +11,3 @@ var app = express(); | ||
app.get('*', function (req, res) { | ||
res.sendfile(__dirname + '/index.html'); | ||
res.sendFile(__dirname + '/index.html'); | ||
}); | ||
@@ -10,0 +14,0 @@ |
@@ -15,4 +15,10 @@ [![NPM](https://nodei.co/npm/rylaijs.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/rylaijs/) | ||
## pushState | ||
```sh | ||
$ npm run pushState | ||
``` | ||
## license | ||
MIT. |
var Request = require("./request"); | ||
var Response = require("./response"); | ||
var _u = require("./utils"); | ||
var pathToRegexp = require('path-to-regexp'); | ||
@@ -17,2 +15,3 @@ | ||
var locals = {}; | ||
var started = false; | ||
var app = { | ||
@@ -68,3 +67,3 @@ get: function () { | ||
var prop = route.k[i - 1].name; | ||
var val = _u.DecodeParam(m[i]); | ||
var val = _u.decodeParam(m[i]); | ||
@@ -100,3 +99,3 @@ if (!!val || !(_u.hasOwnProperty.call(params, prop))) { | ||
} else { | ||
fragment = this.getHash(); | ||
fragment = _u.getHash(); | ||
} | ||
@@ -106,16 +105,5 @@ } | ||
}, | ||
getHash: function (target) { | ||
var match = (target || window).location.href.match(/#(.*)$/); | ||
return match ? match[1] : ''; | ||
}, | ||
getSearch: function () { | ||
var match = location.href.replace(/#.*/, '').match(/\?.+/); | ||
return match ? match[0] : ''; | ||
}, | ||
decodeFragment: function (fragment) { | ||
return decodeURI(fragment.replace(/%25/g, '%2525')); | ||
}, | ||
getPath: function () { | ||
var path = this.decodeFragment( | ||
location.pathname + this.getSearch() | ||
var path = _u.decodeFragment( | ||
location.pathname + _u.getSearch() | ||
).slice(this.root.length - 1); | ||
@@ -126,3 +114,3 @@ return path.charAt(0) === '/' ? path.slice(1) : path; | ||
var path = location.pathname.replace(/[^\/]$/, '$&/'); | ||
return path === this.root && !this.getSearch(); | ||
return path === this.root && !_u.getSearch(); | ||
}, | ||
@@ -133,3 +121,3 @@ checkUrl: function (e) { | ||
if (current === this.fragment && this.iframe) { | ||
current = this.getHash(this.iframe.contentWindow); | ||
current = _u.getHash(this.iframe.contentWindow); | ||
} | ||
@@ -147,3 +135,3 @@ | ||
matchRoot: function () { | ||
var path = this.decodeFragment(location.pathname); | ||
var path = _u.decodeFragment(location.pathname); | ||
var rootPath = path.slice(0, this.root.length - 1) + '/'; | ||
@@ -153,4 +141,4 @@ return rootPath === this.root; | ||
start: function (options) { | ||
if (History.started) throw new Error('Backbone.history has already been started'); | ||
History.started = true; | ||
if (started) throw new Error('history has already been started'); | ||
started = true; | ||
@@ -175,3 +163,3 @@ this.options = _opts; | ||
} else if (this._hasPushState && this.atRoot()) { | ||
this.catch(this.getHash()); | ||
this.catch(_u.getHash()); | ||
} | ||
@@ -223,7 +211,7 @@ } | ||
if (this._checkUrlInterval) clearInterval(this._checkUrlInterval); | ||
History.started = false; | ||
started = false; | ||
}, | ||
listen: function (next) { | ||
(!!next ? next : _u.nothing)(); | ||
this.start(_opts); | ||
(!!next ? next : _u.nothing)(); | ||
}, | ||
@@ -230,0 +218,0 @@ locals: locals |
@@ -7,3 +7,3 @@ module.exports = { | ||
*/ | ||
DecodeParam: function (val) { | ||
decodeParam: function (val) { | ||
if (typeof val !== 'string' || val.length === 0) { | ||
@@ -25,3 +25,14 @@ return val; | ||
nothing: function () { | ||
}, | ||
getHash: function (target) { | ||
var match = (target || window).location.href.match(/#(.*)$/); | ||
return match ? match[1] : ''; | ||
}, | ||
decodeFragment: function (fragment) { | ||
return decodeURI(fragment.replace(/%25/g, '%2525')); | ||
}, | ||
getSearch: function () { | ||
var match = location.href.replace(/#.*/, '').match(/\?.+/); | ||
return match ? match[0] : ''; | ||
} | ||
}; |
Sorry, the diff of this file is not supported yet
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
27657
828
23