koa-cash 5.0.0 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +4 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -155,10 +155,12 @@ module.exports = function (options) {
|
|
|
155
155
|
};
|
|
156
156
|
|
|
157
157
|
//
|
|
158
|
-
// if the content-type was `text` or `text/plain` then don't cache
|
|
158
|
+
// if the content-type was `text` or started with `text/plain` then don't cache
|
|
159
159
|
// (since it's likely cache poisoning or the default Koa `text` being used)
|
|
160
|
+
// NOTE: we use `startsWith` for `text/plain` to handle charset variations
|
|
161
|
+
// (e.g. `text/plain; charset=utf-8` which is Koa's default)
|
|
160
162
|
//
|
|
161
|
-
if (obj.type === 'text' || obj.type
|
|
163
|
+
if (obj.type === 'text' || obj.type?.startsWith('text/plain')) {
|
|
162
164
|
const ext = path.extname(ctx.path);
|
|
163
165
|
if (ext && !TXT_EXTENSIONS.has(ext.toLowerCase())) obj.type = null;
|
|
164
166
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koa-cash",
|
|
3
3
|
"description": "HTTP response caching for Koa. HTTP response caching for Koa. Supports Redis, in-memory store, and more!",
|
|
4
|
-
"version": "5.0.
|
|
4
|
+
"version": "5.0.1",
|
|
5
5
|
"author": "Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)",
|
|
6
6
|
"bugs": {
|
|
7
7
|
"url": "https://github.com/koajs/cash/issues",
|