Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Navigation: Squash document URL if it is a /path1/#/path2/
  • Loading branch information
Gabriel Schulhof committed Aug 19, 2014
commit 9e73c54f23a442a755b29933328607b3a237550b
17 changes: 14 additions & 3 deletions js/navigation/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,14 +287,25 @@ define([
},

squash: function( url, resolutionUrl ) {
var href, cleanedUrl, search, stateIndex,
var href, cleanedUrl, search, stateIndex, docUrl,
isPath = this.isPath( url ),
uri = this.parseUrl( url ),
preservedHash = uri.hash,
uiState = "";

// produce a url against which we can resole the provided path
resolutionUrl = resolutionUrl || (path.isPath(url) ? path.getLocation() : path.getDocumentUrl());
// produce a url against which we can resolve the provided path
if ( !resolutionUrl ) {
if ( isPath ) {
resolutionUrl = path.getLocation();
} else {
docUrl = path.getDocumentUrl( true );
if ( path.isPath( docUrl.hash ) ) {
resolutionUrl = path.squash( docUrl.href );
} else {
resolutionUrl = docUrl.href;
}
}
}

// If the url is anything but a simple string, remove any preceding hash
// eg #foo/bar -> foo/bar
Expand Down