diff --git a/services/github/gist/github-gist-last-commit-redirect.service.js b/services/github/gist/github-gist-last-commit-redirect.service.js new file mode 100644 index 0000000000000..bff653f0a7d39 --- /dev/null +++ b/services/github/gist/github-gist-last-commit-redirect.service.js @@ -0,0 +1,8 @@ +import { redirector } from '../../index.js' + +export default redirector({ + category: 'activity', + route: { base: 'github-gist/last-commit', pattern: ':gistId' }, + transformPath: ({ gistId }) => `/github/gist/last-commit/${gistId}`, + dateAdded: new Date('2022-10-09'), +}) diff --git a/services/github/gist/github-gist-last-commit-redirect.tester.js b/services/github/gist/github-gist-last-commit-redirect.tester.js new file mode 100644 index 0000000000000..b99524249bff9 --- /dev/null +++ b/services/github/gist/github-gist-last-commit-redirect.tester.js @@ -0,0 +1,16 @@ +import { ServiceTester } from '../../tester.js' +export const t = new ServiceTester({ + id: 'GithubGistLastCommitRedirect', + title: 'Github Gist Last Commit Redirect', + pathPrefix: '/github-gist', +}) + +t.create('Last Commit redirect') + .get('/last-commit/a8b8c979d200ffde13cc08505f7a6436', { + followRedirect: false, + }) + .expectStatus(301) + .expectHeader( + 'Location', + '/github/gist/last-commit/a8b8c979d200ffde13cc08505f7a6436.svg' + ) diff --git a/services/github/github-gist-last-commit.service.js b/services/github/gist/github-gist-last-commit.service.js similarity index 76% rename from services/github/github-gist-last-commit.service.js rename to services/github/gist/github-gist-last-commit.service.js index d543e73b948a4..5e68852521b90 100644 --- a/services/github/github-gist-last-commit.service.js +++ b/services/github/gist/github-gist-last-commit.service.js @@ -1,8 +1,8 @@ import Joi from 'joi' -import { formatDate } from '../text-formatters.js' -import { age as ageColor } from '../color-formatters.js' -import { GithubAuthV3Service } from './github-auth-service.js' -import { documentation, errorMessagesFor } from './github-helpers.js' +import { formatDate } from '../../text-formatters.js' +import { age as ageColor } from '../../color-formatters.js' +import { GithubAuthV3Service } from '../github-auth-service.js' +import { documentation, errorMessagesFor } from '../github-helpers.js' const schema = Joi.object({ updated_at: Joi.string().required(), @@ -10,7 +10,7 @@ const schema = Joi.object({ export default class GithubGistLastCommit extends GithubAuthV3Service { static category = 'activity' - static route = { base: 'github-gist/last-commit', pattern: ':gistId' } + static route = { base: 'github/gist/last-commit', pattern: ':gistId' } static examples = [ { title: 'GitHub Gist last commit', diff --git a/services/github/github-gist-last-commit.tester.js b/services/github/gist/github-gist-last-commit.tester.js similarity index 92% rename from services/github/github-gist-last-commit.tester.js rename to services/github/gist/github-gist-last-commit.tester.js index e9e5c4f3cee1e..5d82b48c333fd 100644 --- a/services/github/github-gist-last-commit.tester.js +++ b/services/github/gist/github-gist-last-commit.tester.js @@ -1,4 +1,4 @@ -import { createServiceTester } from '../tester.js' +import { createServiceTester } from '../../tester.js' export const t = await createServiceTester() t.create('last commit in gist (ancient)').get('/871064.json').expectBadge({ diff --git a/services/github/gist/github-gist-stars-redirect.service.js b/services/github/gist/github-gist-stars-redirect.service.js new file mode 100644 index 0000000000000..da42aae573eae --- /dev/null +++ b/services/github/gist/github-gist-stars-redirect.service.js @@ -0,0 +1,8 @@ +import { redirector } from '../../index.js' + +export default redirector({ + category: 'social', + route: { base: 'github/stars/gists', pattern: ':gistId' }, + transformPath: ({ gistId }) => `/github/gist/stars/${gistId}`, + dateAdded: new Date('2022-10-09'), +}) diff --git a/services/github/gist/github-gist-stars-redirect.tester.js b/services/github/gist/github-gist-stars-redirect.tester.js new file mode 100644 index 0000000000000..b28becd8fde24 --- /dev/null +++ b/services/github/gist/github-gist-stars-redirect.tester.js @@ -0,0 +1,16 @@ +import { ServiceTester } from '../../tester.js' +export const t = new ServiceTester({ + id: 'GithubGistStarsRedirect', + title: 'Github Gist Stars Redirect', + pathPrefix: '/github', +}) + +t.create('Stars redirect') + .get('/stars/gists/a8b8c979d200ffde13cc08505f7a6436', { + followRedirect: false, + }) + .expectStatus(301) + .expectHeader( + 'Location', + '/github/gist/stars/a8b8c979d200ffde13cc08505f7a6436.svg' + ) diff --git a/services/github/github-gist-stars.service.js b/services/github/gist/github-gist-stars.service.js similarity index 90% rename from services/github/github-gist-stars.service.js rename to services/github/gist/github-gist-stars.service.js index 05dfaed92b172..44c13b2db749b 100644 --- a/services/github/github-gist-stars.service.js +++ b/services/github/gist/github-gist-stars.service.js @@ -1,9 +1,9 @@ import gql from 'graphql-tag' import Joi from 'joi' -import { metric } from '../text-formatters.js' -import { NotFound } from '../index.js' -import { GithubAuthV4Service } from './github-auth-service.js' -import { documentation as commonDocumentation } from './github-helpers.js' +import { metric } from '../../text-formatters.js' +import { NotFound } from '../../index.js' +import { GithubAuthV4Service } from '../github-auth-service.js' +import { documentation as commonDocumentation } from '../github-helpers.js' const schema = Joi.object({ data: Joi.object({ @@ -28,7 +28,7 @@ export default class GithubGistStars extends GithubAuthV4Service { static category = 'social' static route = { - base: 'github/stars/gists', + base: 'github/gist/stars', pattern: ':gistId', } diff --git a/services/github/github-gist-stars.tester.js b/services/github/gist/github-gist-stars.tester.js similarity index 84% rename from services/github/github-gist-stars.tester.js rename to services/github/gist/github-gist-stars.tester.js index 811e210944ed5..2d88d407452a0 100644 --- a/services/github/github-gist-stars.tester.js +++ b/services/github/gist/github-gist-stars.tester.js @@ -1,5 +1,5 @@ -import { createServiceTester } from '../tester.js' -import { isMetric } from '../test-validators.js' +import { createServiceTester } from '../../tester.js' +import { isMetric } from '../../test-validators.js' export const t = await createServiceTester()