Skip to content

Instantly share code, notes, and snippets.

@ericf
Created September 17, 2013 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericf/6594826 to your computer and use it in GitHub Desktop.
Save ericf/6594826 to your computer and use it in GitHub Desktop.
diff --git a/src/app/js/router.js b/src/app/js/router.js
index 621f627..7a6f955 100644
--- a/src/app/js/router.js
+++ b/src/app/js/router.js
@@ -993,11 +993,12 @@ Y.Router = Y.extend(Router, Y.Base, {
**/
_getRequest: function (src) {
return {
- path : this._getPath(),
- query : this._parseQuery(this._getQuery()),
- url : this._getURL(),
- router: this,
- src : src
+ router : this,
+ path : this._getPath(),
+ query : this._parseQuery(this._getQuery()),
+ url : this._getURL(),
+ referrer: Y.Router._referrer,
+ src : src
};
},
@@ -1448,7 +1449,10 @@ Y.Router = Y.extend(Router, Y.Base, {
currentURL = self._getURL(),
req, res;
- self._url = currentURL;
+ // Update the shared `referrer` to the old URL (origin + path + query),
+ // and store the current URL.
+ Y.Router._referrer = prevURL.replace(this._regexURL, '$1$2$3');
+ self._url = currentURL;
// Handles the awkwardness that is the `popstate` event. HTML5 browsers
// fire `popstate` right before they fire `hashchange`, and Chrome fires
@@ -1582,6 +1586,10 @@ Y.Router = Y.extend(Router, Y.Base, {
// To make this testable.
_instances: instances,
+ // Used to store the referrer URL for all router instances in the current
+ // YUI instnace and document.
+ _referrer: Y.config.doc.referrer,
+
/**
Dispatches to the first route handler that matches the specified `path` for
all active router instances.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment