Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 1.1KB

12345678910111213141516171819202122232425262728
  1. "use strict"
  2. Object.defineProperty(exports, "__esModule", { value: true })
  3. const ALLOWED_TOKENS = new Set(["no-referrer", "no-referrer-when-downgrade", "same-origin", "origin", "strict-origin", "origin-when-cross-origin", "strict-origin-when-cross-origin", "unsafe-url", ""])
  4. function getHeaderValueFromOptions({ policy = ["no-referrer"] }) {
  5. const tokens = typeof policy === "string" ? [policy] : policy
  6. if (tokens.length === 0) {
  7. throw new Error("Referrer-Policy received no policy tokens")
  8. }
  9. const tokensSeen = new Set()
  10. tokens.forEach(token => {
  11. if (!ALLOWED_TOKENS.has(token)) {
  12. throw new Error(`Referrer-Policy received an unexpected policy token ${JSON.stringify(token)}`)
  13. } else if (tokensSeen.has(token)) {
  14. throw new Error(`Referrer-Policy received a duplicate policy token ${JSON.stringify(token)}`)
  15. }
  16. tokensSeen.add(token)
  17. })
  18. return tokens.join(",")
  19. }
  20. function referrerPolicy(options = {}) {
  21. const headerValue = getHeaderValueFromOptions(options)
  22. return function referrerPolicyMiddleware(_req, res, next) {
  23. res.setHeader("Referrer-Policy", headerValue)
  24. next()
  25. }
  26. }
  27. module.exports = referrerPolicy
  28. exports.default = referrerPolicy