summaryrefslogtreecommitdiff
path: root/api/headers.js
blob: 9cbf6ac3faadfd3ed3b79a7597ea4eb746d28d40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
// headers.js
export default (req, res) => {
    const headers = res.headers();
    for (const key in headers) {
      const value = headers[key];
      if (typeof value === 'string') {
        headers[key] = value.replace(/[^\x00-\x7F]/g, (char) => {
          return `%${char.charCodeAt(0).toString(16).toUpperCase()}`;
        });
      }
    }
    return res;
  };