DemocracyOS/democracyos

View on GitHub
lib/facebook-card/middleware.js

Summary

Maintainability
A
2 hrs
Test Coverage
var path = require('path')
var join = path.join

module.exports = function middleware (req, res, next) {
  if (!req.headers['user-agent']) return next()
  if (/facebookexternalhit/.test(req.headers['user-agent'])) {
    req.url = join('/facebook-card', req.url)
  }
  next()
}