This is the preferred way we’re handling server URLs: in the query string. While we still have a mix of these, I’ve argued this way is better for these reasons: 1. It allows us to make the URLs a bit more standardized across services. 2. It makes the routes unambiguous. 3. It requires less code. While it introduces a URL-encoding requirement on the parameter, I think these tradeoffs are worth it.
36 lines
986 B
JavaScript
36 lines
986 B
JavaScript
'use strict'
|
|
|
|
const { redirector } = require('..')
|
|
|
|
module.exports = [
|
|
redirector({
|
|
name: 'SonarVersionPrefixRedirector',
|
|
category: 'analysis',
|
|
route: {
|
|
base: 'sonar',
|
|
pattern:
|
|
':sonarVersion/:protocol(http|https)/:host(.+)/:component(.+)/:metric',
|
|
},
|
|
transformPath: ({ protocol, host, component, metric }) =>
|
|
`/sonar/${metric}/${component}`,
|
|
transformQueryParams: ({ protocol, host, sonarVersion }) => ({
|
|
server: `${protocol}://${host}`,
|
|
sonarVersion,
|
|
}),
|
|
dateAdded: new Date('2019-07-05'),
|
|
}),
|
|
redirector({
|
|
name: 'SonarServerRedirector',
|
|
category: 'coverage',
|
|
route: {
|
|
base: 'sonar',
|
|
pattern: ':protocol(http|https)/:host(.+)/:component(.+)/:metric',
|
|
},
|
|
transformPath: ({ component, metric }) => `/sonar/${metric}/${component}`,
|
|
transformQueryParams: ({ protocol, host }) => ({
|
|
server: `${protocol}://${host}`,
|
|
}),
|
|
dateAdded: new Date('2019-07-05'),
|
|
}),
|
|
]
|