Skip to content

Commit

Permalink
fix(http): fix data url regex pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Jun 6, 2024
1 parent d033173 commit f6138b5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,8 @@ export class HTTP extends Service<HTTP.Config> {
async file(this: HTTP, url: string, options: FileOptions = {}): Promise<FileResponse> {
const task = await this[Context.origin].serial(this, 'http/file', url, options)
if (task) return task
const capture = /^data:([\w/-]+);base64,(.*)$/.exec(url)
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
const capture = /^data:([\w/.+-]+);base64,(.*)$/.exec(url)
if (capture) {
const [, type, base64] = capture
let name = 'file'
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"compilerOptions": {
"target": "es2022",
"module": "nodenext",
"module": "esnext",
"moduleResolution": "bundler",
"declaration": true,
"emitDeclarationOnly": true,
"strict": true,
Expand Down

0 comments on commit f6138b5

Please sign in to comment.