From 711f92a7c13b73544cd0fbc8e8a9c973b5900583 Mon Sep 17 00:00:00 2001 From: Yoshua Wuyts Date: Sat, 1 Jul 2017 13:50:14 +0200 Subject: [PATCH] use nanolocation (#523) --- index.js | 8 ++------ package.json | 1 + 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index b0bffc6..d89a875 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,6 @@ var scrollToAnchor = require('scroll-to-anchor') var documentReady = require('document-ready') +var nanolocation = require('nanolocation') var nanotiming = require('nanotiming') var nanorouter = require('nanorouter') var nanomorph = require('nanomorph') @@ -32,6 +33,7 @@ function Choo (opts) { // properties for internal use only this._historyEnabled = opts.history === undefined ? true : opts.history this._hrefEnabled = opts.href === undefined ? true : opts.href + this._createLocation = nanolocation this._tree = null // properties that are part of the API @@ -172,9 +174,3 @@ Choo.prototype.toString = function (location, state) { assert.ok(html, 'choo.toString: no valid value returned for the route ' + location) return html.toString() } - -Choo.prototype._createLocation = function () { - var pathname = window.location.pathname.replace(/\/$/, '') - var hash = window.location.hash.replace(/^#/, '/') - return pathname + hash -} diff --git a/package.json b/package.json index 3c7afb4..0495d26 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "document-ready": "^2.0.1", "nanobus": "^4.2.0", "nanohref": "^2.0.0", + "nanolocation": "^1.0.0", "nanomorph": "^5.1.2", "nanoquery": "^1.1.0", "nanoraf": "^3.0.0",