2
.github/workflows/lint-code.yml
vendored
2
.github/workflows/lint-code.yml
vendored
@@ -20,8 +20,6 @@ on:
|
||||
- 'package-lock.json'
|
||||
# In case one of the script definitions changed
|
||||
- 'package.json'
|
||||
# Ultimately, for debugging this workflow itself
|
||||
- .github/workflows/code-lint.yml
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
@@ -32,7 +32,7 @@ jobs:
|
||||
- You can only merge this PR if it's had a technical review (see who's approved it in the 'Reviewers' section in the top right corner).
|
||||
- To test that the changes appear on Staging, look at the preview of the 'Secret scanning patterns' file. You may need to use the product picker to look at the table for different GitHub products, and test the versioning.
|
||||
- If you don't feel comfortable reviewing this PR, please post a link to it in the #code-security-docs Slack channel so someone from the Dependencies & Secrets focus team can take a look.
|
||||
|
||||
|
||||
- For more information about this automation, and the reasons why we've decided to implement it, see [About automations for Dependencies & Secrets](https://github.com/github/docs-content/blob/main/focus-areas/code-security/about-automations-for-dependencies-and-secrets.md#secret-scanning-prs-adding-new-supported-patterns) in the `docs-content` repository.
|
||||
|
||||
- Thank you :fishsticks: :sparkling_heart:"
|
||||
|
||||
@@ -17,16 +17,24 @@ const MAP = {
|
||||
contentType: 'image/png',
|
||||
buffer: getBuffer('assets/images/site/apple-touch-icon.png'),
|
||||
},
|
||||
// It's the same image but it's fine. By default, when Safari tries to
|
||||
// to figure out which apple touch icons are available it will
|
||||
// try to load this by default. For example, if you in desktop Safari
|
||||
// click share icon, it will load this to serve as a preview icon.
|
||||
'/apple-touch-icon-precomposed.png': {
|
||||
'/apple-touch-icon-120x120.png': {
|
||||
contentType: 'image/png',
|
||||
buffer: getBuffer('assets/images/site/apple-touch-icon.png'),
|
||||
buffer: getBuffer('assets/images/site/apple-touch-icon-120x120.png'),
|
||||
},
|
||||
'/apple-touch-icon-152x152.png': {
|
||||
contentType: 'image/png',
|
||||
buffer: getBuffer('assets/images/site/apple-touch-icon-152x152.png'),
|
||||
},
|
||||
}
|
||||
|
||||
// It's the same image but it's fine. By default, when Safari tries to
|
||||
// to figure out which apple touch icons are available it will
|
||||
// try to load this by default. For example, if you in desktop Safari
|
||||
// click share icon, it will load this to serve as a preview icon.
|
||||
MAP['/apple-touch-icon-precomposed.png'] = MAP['/apple-touch-icon.png']
|
||||
MAP['/apple-touch-icon-120x120-precomposed.png'] = MAP['/apple-touch-icon-120x120.png']
|
||||
MAP['/apple-touch-icon-152x152-precomposed.png'] = MAP['/apple-touch-icon-152x152.png']
|
||||
|
||||
function getBuffer(filePath) {
|
||||
let buffer
|
||||
if (!fs.existsSync(filePath)) {
|
||||
|
||||
@@ -10,12 +10,15 @@ import { isConnectionDropped } from './halt-on-dropped-connection.js'
|
||||
import { nextApp, nextHandleRequest } from './next.js'
|
||||
import { defaultCacheControl } from './cache-control.js'
|
||||
|
||||
const STATSD_KEY_RENDER = 'middleware.render_page'
|
||||
const STATSD_KEY_404 = 'middleware.render_404'
|
||||
|
||||
async function buildRenderedPage(req) {
|
||||
const { context } = req
|
||||
const { page } = context
|
||||
const path = req.pagePath || req.path
|
||||
|
||||
const pageRenderTimed = statsd.asyncTimer(page.render, 'middleware.render_page', [`path:${path}`])
|
||||
const pageRenderTimed = statsd.asyncTimer(page.render, STATSD_KEY_RENDER, [`path:${path}`])
|
||||
|
||||
return await pageRenderTimed(context)
|
||||
}
|
||||
@@ -51,6 +54,14 @@ export default async function renderPage(req, res) {
|
||||
`\nTried to redirect to ${context.redirectNotFound}, but that page was not found.\n`
|
||||
)
|
||||
}
|
||||
|
||||
statsd.increment(STATSD_KEY_404, 1, [
|
||||
`url:${req.url}`,
|
||||
`ip:${req.ip}`,
|
||||
`path:${req.path}`,
|
||||
`referer:${req.headers.referer || ''}`,
|
||||
])
|
||||
|
||||
return nextApp.render404(req, res)
|
||||
}
|
||||
|
||||
|
||||
@@ -38,8 +38,14 @@ describe('favicon assets', () => {
|
||||
expect(res.headers['surrogate-key']).toBe(SURROGATE_ENUMS.MANUAL)
|
||||
})
|
||||
|
||||
test('should also 200 OK on /apple-touch-icon-precomposed.png', async () => {
|
||||
const res = await get('/apple-touch-icon-precomposed.png')
|
||||
test.each([
|
||||
'/apple-touch-icon-precomposed.png',
|
||||
'/apple-touch-icon-120x120-precomposed.png',
|
||||
'/apple-touch-icon-120x120.png',
|
||||
'/apple-touch-icon-152x152.png',
|
||||
'/apple-touch-icon-152x152-precomposed.png',
|
||||
])('should also 200 OK on %s', async (path) => {
|
||||
const res = await get(path)
|
||||
expect(res.statusCode).toBe(200)
|
||||
expect(res.headers['content-type']).toBe('image/png')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user