Skip to content

Commit 3b19fe9

Browse files
committed
feat(file): add href property to File class
1 parent 5b45de3 commit 3b19fe9

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@secjs/utils",
3-
"version": "1.9.1",
3+
"version": "1.9.2",
44
"description": "Utils functions and classes for Node.js",
55
"license": "MIT",
66
"author": "João Lenon <lenon@athenna.io>",

src/Helpers/File.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,16 @@ import {
2323
} from 'node:fs'
2424

2525
import { lookup } from 'mime-types'
26+
import { pathToFileURL } from 'node:url'
2627
import { randomBytes } from 'node:crypto'
2728
import { isAbsolute, parse, sep } from 'node:path'
2829

30+
import { Path } from '#src/Helpers/Path'
2931
import { Json } from '#src/Helpers/Json'
3032
import { Debug } from '#src/Helpers/Debug'
3133
import { Parser } from '#src/Helpers/Parser'
3234
import { Options } from '#src/Helpers/Options'
3335
import { NotFoundFileException } from '#src/Exceptions/NotFoundFileException'
34-
import { Path } from '#src/Helpers/Path'
3536

3637
export class File {
3738
/**
@@ -238,6 +239,7 @@ export class File {
238239
name: this.name,
239240
base: this.base,
240241
path: this.path,
242+
href: this.href,
241243
mime: this.mime,
242244
createdAt: this.createdAt,
243245
accessedAt: this.accessedAt,
@@ -682,6 +684,7 @@ export class File {
682684
this.name = buffer.toString('base64').replace(/[^a-zA-Z0-9]/g, '')
683685
this.base = this.name + this.extension
684686
this.path = this.dir + '/' + this.base
687+
this.href = pathToFileURL(this.path).href
685688

686689
return
687690
}

src/index.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ export declare class File {
170170
public base: string
171171

172172
public path: string
173+
174+
public href: string
173175

174176
public isCopy: boolean
175177

0 commit comments

Comments
 (0)