Skip to content

Instantly share code, notes, and snippets.

@RafaelKr
Created January 18, 2020 23:28
Show Gist options
  • Save RafaelKr/155a570ec4bb1835ed660aba731ddd9b to your computer and use it in GitHub Desktop.
Save RafaelKr/155a570ec4bb1835ed660aba731ddd9b to your computer and use it in GitHub Desktop.
Header Editor config to allow loading Fira Code font on github.com and gitlab.com, see https://medium.com/@sportebois/how-to-make-online-code-easier-to-read-with-custom-font-with-ligatures-d6daa2c89325
{
"request": [],
"sendHeader": [],
"receiveHeader": [
{
"enable": true,
"name": "Fira Code",
"ruleType": "modifyReceiveHeader",
"matchType": "regexp",
"pattern": "^http[s]*:\\/\\/(?:[^/\\.]+\\.)*(?:github\\.com|gitlab\\.com)\\/",
"exclude": "",
"group": "Content-Security-Policy Extensions",
"isFunction": true,
"code": "// Rule for https://medium.com/@sportebois/how-to-make-online-code-easier-to-read-with-custom-font-with-ligatures-d6daa2c89325\n\nconst cspHeader = Object\n .values(val)\n .find((header) => header.name.toLowerCase() === 'content-security-policy')\n\nif (cspHeader) {\n cspHeader.value = cspHeader.value\n .replace(/(connect-src[^;]*)/, '$1 https://cdn.rawgit.com/tonsky/FiraCode/')\n .replace(/(style-src[^;]*)/, '$1 https://cdn.rawgit.com/tonsky/FiraCode/')\n .replace(/(font-src[^;]*)/, '$1 https://cdn.rawgit.com/tonsky/FiraCode/')\n}\n\n"
}
],
"receiveBody": []
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment