mirror of https://github.com/docker/docs.git
Fix for substring matching in redirects
This commit is contained in:
parent
4a833da9f3
commit
778f02e599
24
404.md
24
404.md
|
@ -9,10 +9,20 @@ permalink: /404.html
|
|||
if (forwardingURL.charAt(forwardingURL.length - 1) != "/") forwardingURL += "/";
|
||||
var gonnaFwd = false;
|
||||
var newURL = "";
|
||||
var baseURL = "";
|
||||
console.log(forwardingURL);
|
||||
{% for item in site.data.docsarchive.docker-compose %}
|
||||
if (forwardingURL.indexOf("/{{ item[0] }}") > -1)
|
||||
{
|
||||
console.log("Found via Docker Compose file for Acrhive")
|
||||
gonnaFwd = true;
|
||||
// make it so redirects cascade; first, use the base URL, then append path
|
||||
baseURL = forwardingURL.replace("/{{ item[0] }}","{{ page.archiveserver }}:{{ item[1].ports[0] | replace:':4000','' }}");
|
||||
forwardingURL = forwardingURL.replace("/{{ item[0] }}","");
|
||||
}{% endfor %}
|
||||
{% for item in site.data.redirects %}
|
||||
var redirectVal = {{ item | jsonify }};
|
||||
if (forwardingURL.indexOf(redirectVal.source) > -1)
|
||||
if (forwardingURL == redirectVal.source)
|
||||
{
|
||||
console.log("Found via CSV @ ", redirectVal.source, redirectVal.destination);
|
||||
gonnaFwd = true;
|
||||
|
@ -25,7 +35,7 @@ permalink: /404.html
|
|||
// aliases is an array, therefore, there are multiple aliases
|
||||
for (i=0; i< aliases.length; i++)
|
||||
{
|
||||
if (forwardingURL.indexOf(aliases[i]) > -1)
|
||||
if (forwardingURL == aliases[i])
|
||||
{
|
||||
console.log("Found via Page Aliases on a multi-alias page @", "{{ page.url }}", aliases[i])
|
||||
gonnaFwd = true;
|
||||
|
@ -34,7 +44,7 @@ permalink: /404.html
|
|||
}
|
||||
} else {
|
||||
// only one alias for this page.
|
||||
if (forwardingURL.indexOf(aliases) > -1)
|
||||
if (forwardingURL == aliases)
|
||||
{
|
||||
console.log("Found via Page Aliases on a single-alias page @", forwardingURL.indexOf(aliases[i]), aliases[i])
|
||||
gonnaFwd = true;
|
||||
|
@ -42,14 +52,8 @@ permalink: /404.html
|
|||
}
|
||||
}
|
||||
{% endif %}{% endfor %}
|
||||
{% for item in site.data.docsarchive.docker-compose %}
|
||||
if (forwardingURL.indexOf("/{{ item[0] }}") > -1)
|
||||
{
|
||||
console.log("Found via Docker Compose file for Acrhive")
|
||||
gonnaFwd = true;
|
||||
newURL = forwardingURL.replace("/{{ item[0] }}","{{ page.archiveserver }}:{{ item[1].ports[0] | replace:':4000','' }}");
|
||||
}{% endfor %}
|
||||
if (gonnaFwd) {
|
||||
newURL = baseURL + newURL;
|
||||
console.log("Forwarding to: " + newURL);
|
||||
window.location.replace(newURL);
|
||||
window.location.href = newURL;
|
||||
|
|
Loading…
Reference in New Issue