| | import { describe, expect, test } from 'vitest' |
| | import { get } from '@/tests/helpers/e2etest' |
| |
|
| | describe('URL encoding for version paths', () => { |
| | test('handles URL-encoded @ symbol in enterprise-cloud version', async () => { |
| | |
| | const encodedUrl = '/en/enterprise-cloud%40latest/copilot/concepts/chat' |
| | const res = await get(encodedUrl) |
| |
|
| | |
| | |
| | |
| | |
| | expect([200, 301, 302]).toContain(res.statusCode) |
| |
|
| | if (res.statusCode === 301 || res.statusCode === 302) { |
| | |
| | expect(res.headers.location).toBe('/en/enterprise-cloud@latest/copilot/concepts/chat') |
| | } |
| | }) |
| |
|
| | test('handles URL-encoded @ symbol in enterprise-server version', async () => { |
| | const encodedUrl = |
| | '/en/enterprise-server%403.17/admin/managing-github-actions-for-your-enterprise' |
| | const res = await get(encodedUrl) |
| |
|
| | expect([200, 301, 302]).toContain(res.statusCode) |
| |
|
| | if (res.statusCode === 301 || res.statusCode === 302) { |
| | expect(res.headers.location).toBe( |
| | '/en/enterprise-server@3.17/admin/managing-github-actions-for-your-enterprise', |
| | ) |
| | } |
| | }) |
| |
|
| | test('handles URL-encoded @ symbol in second path segment', async () => { |
| | |
| | const encodedUrl = '/enterprise-cloud%40latest/copilot/concepts/chat' |
| | const res = await get(encodedUrl) |
| |
|
| | |
| | expect([301, 302]).toContain(res.statusCode) |
| | expect(res.headers.location).toBe('/en/enterprise-cloud@latest/copilot/concepts/chat') |
| | }) |
| |
|
| | test('normal @ symbol paths continue to work', async () => { |
| | |
| | const normalUrl = '/en/enterprise-cloud@latest/copilot/concepts/chat' |
| | const res = await get(normalUrl) |
| |
|
| | expect(res.statusCode).toBe(200) |
| | }) |
| |
|
| | test('URL encoding in other parts of URL is preserved', async () => { |
| | |
| | const encodedUrl = '/en/enterprise-cloud@latest/copilot/concepts/some%20page' |
| | const res = await get(encodedUrl) |
| |
|
| | |
| | expect(res.statusCode).not.toBe(500) |
| | }) |
| |
|
| | test('Express URL properties are correctly updated after decoding', async () => { |
| | |
| | const encodedUrl = '/en/enterprise-cloud%40latest/copilot/concepts/chat?test=value' |
| | const res = await get(encodedUrl) |
| |
|
| | |
| | |
| | expect([200, 301, 302]).toContain(res.statusCode) |
| | }) |
| | }) |
| |
|