forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Branch was updated using the 'autoupdate branch' Actions workflow.
- Loading branch information
Showing
5 changed files
with
83 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,6 +50,22 @@ module.exports = async function precompileRedirects (pages) { | |
const developerRouteWithLanguage = `/en${developerRoute}` | ||
allRedirects[developerRouteWithLanguage] = newPath | ||
|
||
// TODO until we update all the old /v3 and /v4 links, we need to support redirects | ||
// from the old /enterprise/<number>/v3 format to the new /enterprise-server@<number/rest format | ||
// AS WELL AS /enterprise-server@<number/v3 to /enterprise-server@<number/rest. | ||
// This is because the new format gets created dynamically even when the links point to /v3 or /v4. | ||
// EXAMPLES: | ||
// /en/enterprise/2.20/v3/pulls/comments -> /en/[email protected]/rest/reference/pulls#comments | ||
// /en/[email protected]/v3/pulls/comments -> /en/[email protected]/rest/reference/pulls#comments | ||
// NOTE: after we update all the /v3 and /v4 links, we can yank the following block | ||
if (developerRoute.includes('/enterprise/')) { | ||
const developerRouteWithNewFormat = developerRoute.replace(/\/enterprise\/(\d.\d\d)\//, '/enterprise-server@$1/') | ||
const developerRouteWithNewFormatWithLanguage = `/en${developerRouteWithNewFormat}` | ||
allRedirects[developerRouteWithNewFormat] = newPath | ||
allRedirects[developerRouteWithNewFormatWithLanguage] = newPath | ||
} | ||
// TODO ENDYANK | ||
|
||
// although we only support developer Enterprise paths up to 2.21, we make | ||
// an exception to always redirect versionless paths to the latest version | ||
if (developerRoute.includes('/2.21/')) { | ||
|
@@ -58,18 +74,32 @@ module.exports = async function precompileRedirects (pages) { | |
const developerRouteWithLanguageWithoutVersion = `/en${developerRouteWithoutVersion}` | ||
allRedirects[developerRouteWithoutVersion] = newPathOnLatestVersion | ||
allRedirects[developerRouteWithLanguageWithoutVersion] = newPathOnLatestVersion | ||
// TODO after we update all the /v3 and /v4 links, we can yank the following | ||
const developerRouteWithoutVersionWithNewFormat = developerRouteWithoutVersion | ||
.replace('/enterprise/', 'enterprise-server') | ||
const developerRouteWithoutVersionWithNewFormatWithLanguage = `/en${developerRouteWithoutVersionWithNewFormat}` | ||
allRedirects[developerRouteWithoutVersionWithNewFormat] = newPathOnLatestVersion | ||
allRedirects[developerRouteWithoutVersionWithNewFormatWithLanguage] = newPathOnLatestVersion | ||
// TODO ENDYANK | ||
} | ||
|
||
// TODO: TEMPORARILY support explicit 2.22 redirects (created on page render by lib/rewrite-local-links) | ||
// we should eventually yank this block because 2.22 never existed on developer site | ||
// the better solution is to change `/v3` and `/v4` links in content to `/rest` and `/graphql` | ||
// after we update `/v3` and `/v4` links everywhere to `/rest` and `/graphql`, we can | ||
// yank this entire block because 2.22 never existed on developer site | ||
if (developerRoute.includes('/2.21/')) { | ||
const newPath222 = newPath.replace('@2.21/', '@2.22/') | ||
const developerRoute222 = developerRoute.replace('/2.21/', '/2.22/') | ||
const developerRouteWithLanguage222 = `/en${developerRoute222}` | ||
allRedirects[developerRoute222] = newPath222 | ||
allRedirects[developerRouteWithLanguage222] = newPath222 | ||
|
||
const developerRouteWithNewFormat222 = developerRoute222 | ||
.replace('/enterprise/2.22/', '/[email protected]/') | ||
const developerRouteWithNewFormatWithLanguage222 = `/en${developerRouteWithNewFormat222}` | ||
allRedirects[developerRouteWithNewFormat222] = newPath222 | ||
allRedirects[developerRouteWithNewFormatWithLanguage222] = newPath222 | ||
} | ||
// TODO ENDYANK | ||
|
||
// given a developer route like `/enterprise/2.19/v3/activity`, | ||
// add a veriation like `/enterprise/2.19/user/v3/activity`; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
const { eachOfLimit } = require('async') | ||
const enterpriseServerReleases = require('../../lib/enterprise-server-releases') | ||
const { get } = require('../helpers') | ||
const { getEnterpriseVersionNumber } = require('../../lib/patterns') | ||
const nonEnterpriseDefaultVersion = require('../../lib/non-enterprise-default-version') | ||
const restRedirectFixtures = require('../fixtures/rest-redirects') | ||
const graphqlRedirectFixtures = require('../fixtures/graphql-redirects') | ||
|
@@ -125,6 +126,29 @@ describe('developer redirects', () => { | |
) | ||
}) | ||
|
||
// TODO temprarily ensure we redirect old links using the new enterprise format | ||
// for currently supported enterprise releases only | ||
// EXAMPLE: /en/[email protected]/v3/pulls/comments -> /en/[email protected]/rest/reference/pulls#comments | ||
// We can remove test after we update all the old `/v3` links to point to `/rest` | ||
test('temporary rest reference enterprise redirects', async () => { | ||
await eachOfLimit( | ||
restRedirectFixtures, | ||
MAX_CONCURRENT_REQUESTS, | ||
async (newPath, oldPath) => { | ||
const releaseNumber = oldPath.match(getEnterpriseVersionNumber) | ||
if (!releaseNumber) return | ||
if (!enterpriseServerReleases.supported.includes(releaseNumber[1])) return | ||
|
||
oldPath = oldPath | ||
.replace(/\/enterprise\/(\d.\d\d)\//, '/enterprise-server@$1/') | ||
.replace('/user/', '/') | ||
const res = await get(oldPath) | ||
expect(res.statusCode, `${oldPath} did not redirect to ${newPath}`).toBe(301) | ||
expect(res.headers.location).toBe(newPath) | ||
} | ||
) | ||
}) | ||
|
||
// this fixtures file includes /v4 and /enterprise/v4 paths | ||
test('graphql reference redirects', async () => { | ||
await eachOfLimit( | ||
|
@@ -140,5 +164,28 @@ describe('developer redirects', () => { | |
} | ||
) | ||
}) | ||
|
||
// TODO temprarily ensure we redirect old links using the new enterprise format | ||
// for currently supported enterprise releases only | ||
// EXAMPLE: /en/[email protected]/v4/interface/actor -> /en/[email protected]/graphql/reference/interfaces#actor | ||
// We can remove test after we update all the old `/v4` links to point to `/graphql` | ||
test('temporary rest reference enterprise redirects', async () => { | ||
await eachOfLimit( | ||
graphqlRedirectFixtures, | ||
MAX_CONCURRENT_REQUESTS, | ||
async (newPath, oldPath) => { | ||
const releaseNumber = oldPath.match(getEnterpriseVersionNumber) | ||
if (!releaseNumber) return | ||
if (!enterpriseServerReleases.supported.includes(releaseNumber[1])) return | ||
|
||
oldPath = oldPath | ||
.replace(/\/enterprise\/(\d.\d\d)\//, '/enterprise-server@$1/') | ||
.replace('/user/', '/') | ||
const res = await get(oldPath) | ||
expect(res.statusCode, `${oldPath} did not redirect to ${newPath}`).toBe(301) | ||
expect(res.headers.location).toBe(newPath) | ||
} | ||
) | ||
}) | ||
}) | ||
}) |