diff --git a/src/node/utils.ts b/src/node/utils.ts index 24a0a48a0ca30f..ea3f374faa0552 100644 --- a/src/node/utils.ts +++ b/src/node/utils.ts @@ -3,6 +3,7 @@ import { promises as fs } from 'fs' import LRUCache from 'lru-cache' import { Context } from 'koa' import { Readable } from 'stream' +import { URL } from 'url' const getETag = require('etag') const imageRE = /\.(png|jpe?g|gif|svg)(\?.*)?$/ @@ -23,7 +24,7 @@ export const isStaticAsset = (file: string) => { * as well. */ export const isImportRequest = (ctx: Context) => { - const referer = ctx.get('referer') + const referer = new URL(ctx.get('referer')).pathname return /\.\w+$/.test(referer) && !referer.endsWith('.html') }