diff --git a/js/redirect.js b/js/redirect.js index 877593a3..84d1c69b 100644 --- a/js/redirect.js +++ b/js/redirect.js @@ -1,11 +1,26 @@ (function($) { - var PATH = location.pathname, HASH = location.hash, EXTENSION = '', PATH_SPACE = '-', HASH_SPACE = '-'; + var PATH = location.pathname + , HASH = location.hash + , EXTENSION = '' + , PATH_SPACE = '-' + , HASH_SPACE = '-' + , customRedirects; + + customRedirects = { + '#header-subaccounts': '/api/subaccounts#header-introduction', + '#header-terminology': '/api/subaccounts#header-terminology', + '#header-managing-subaccount-data-as-a-service-provider': '/api/subaccounts#header-managing-subaccount-data-as-a-service-provider', + '#header-managing-master-account-data-as-a-service-provider': '/api/subaccounts#header-managing-master-account-data-as-a-service-provider' + }; // check if we are on the API page with an Apiary hash - if ((PATH === '/api/' || PATH === '/api/index.html') && (HASH.indexOf('introduction') >= 0 || HASH.indexOf('reference') >= 0)) { - var newPath = convertHashToPath(HASH); - - redirect(location.protocol + '//' + location.host + PATH + newPath); + if (PATH === '/api/' || PATH === '/api/index' || PATH === '/api/index.html') { + if (HASH.indexOf('introduction') >= 0 || HASH.indexOf('reference') >= 0) { + var newPath = convertHashToPath(HASH); + redirect(location.protocol + '//' + location.host + PATH + newPath); + } else if (HASH in customRedirects) { + redirect(location.protocol + '//' + location.host + customRedirects[HASH]); + } }