提交 0dc9803a 编写于 作者: S Samy Pessé

Use header 'X-Current-Location' for ajax navigation

上级 d94ae0f8
...@@ -65,7 +65,6 @@ function handleNavigation(relativeUrl, push) { ...@@ -65,7 +65,6 @@ function handleNavigation(relativeUrl, push) {
} }
prevUri = uri; prevUri = uri;
uri = './plugins'; //
var promise = $.Deferred(function(deferred) { var promise = $.Deferred(function(deferred) {
$.ajax({ $.ajax({
...@@ -73,11 +72,11 @@ function handleNavigation(relativeUrl, push) { ...@@ -73,11 +72,11 @@ function handleNavigation(relativeUrl, push) {
url: uri, url: uri,
cache: true, cache: true,
headers:{ headers:{
'Access-Control-Expose-Headers': 'Location' 'Access-Control-Expose-Headers': 'X-Current-Location'
}, },
success: function(html, status, xhr) { success: function(html, status, xhr) {
console.log(xhr, xhr.getAllResponseHeaders()); // For GitBook.com, we handle redirection signaled by the server
alert('responseURL:' + xhr.responseURL); var responseURL = xhr.getResponseHeader('X-Current-Location') || uri;
// Replace html content // Replace html content
html = html.replace( /<(\/?)(html|head|body)([^>]*)>/ig, function(a,b,c,d){ html = html.replace( /<(\/?)(html|head|body)([^>]*)>/ig, function(a,b,c,d){
...@@ -97,8 +96,8 @@ function handleNavigation(relativeUrl, push) { ...@@ -97,8 +96,8 @@ function handleNavigation(relativeUrl, push) {
// Push url to history // Push url to history
if (push) { if (push) {
history.pushState({ history.pushState({
path: uri path: responseURL
}, null, uri); }, null, responseURL);
} }
// Merge heads // Merge heads
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册