Created
July 6, 2018 06:27
-
-
Save junderw/fe0c43783f43f72d246ea4ea24dae60c to your computer and use it in GitHub Desktop.
An efficient way of writing CSP directives in NodeJS using template literals. (You can copy and paste URLs, domains, whatever from excel sheet columns and vice versa)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const CSP_DIRECTIVES = ` | |
default-src | |
'self' | |
; | |
object-src | |
'none' | |
; | |
report-uri | |
someURL | |
`.trim().replace(/\n/g, " ").replace(/ ;/g, ";") | |
// turns into | |
// "default-src 'self'; object-src 'none'; report-uri someURL" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment