Skip to content

Commit

Permalink
docs(legacy): add test case to ensure correct csp hashes in readme.md (
Browse files Browse the repository at this point in the history
…#13384)

Co-authored-by: sapphi-red <[email protected]>
  • Loading branch information
KAROTT7 and sapphi-red authored Jun 1, 2023
1 parent 2872d55 commit bf0cd25
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/plugin-legacy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ The legacy plugin requires inline scripts for [Safari 10.1 `nomodule` fix](https

- `sha256-MS6/3FCg4WjP9gwgaBGwLpRCY6fZBgwmhVCdrPrNf3E=`
- `sha256-tQjf8gvb2ROOMapIxFvFAYBeUJ0v1HCbOcSmDNXGtDo=`
- `sha256-p7PoC97FO+Lu90RNjGWxhbm13yALSR4xzV8vaDhaQBo=`
- `sha256-4y/gEB2/KIwZFTfNqwXJq4olzvmQ0S214m9jwKgNXoc=`
- `sha256-+5XkZFazzJo8n0iOP4ti/cLCMUudTf//Mzkb7xNPXIc=`

<!--
Expand Down
16 changes: 16 additions & 0 deletions packages/plugin-legacy/src/__tests__/readme.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import fs from 'node:fs'
import path from 'node:path'
import { expect, test } from 'vitest'
import { cspHashes } from '..'

test('CSP hashes in README.md should be correct', () => {
const readme = fs.readFileSync(
path.resolve(__dirname, '../../README.md'),
'utf-8',
)
const hashesInDoc = [...readme.matchAll(/`sha256-(.+)`/g)].map(
(match) => match[1],
)

expect(hashesInDoc).toStrictEqual(cspHashes)
})

0 comments on commit bf0cd25

Please sign in to comment.