From 3b19fe95a0d9b3621eb9dddebec0de04d4a760a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Lenon?= Date: Sun, 1 May 2022 10:16:16 -0300 Subject: [PATCH] feat(file): add href property to File class --- package.json | 2 +- src/Helpers/File.js | 5 ++++- src/index.d.ts | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 1c6eefd..9db87ce 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@secjs/utils", - "version": "1.9.1", + "version": "1.9.2", "description": "Utils functions and classes for Node.js", "license": "MIT", "author": "João Lenon ", diff --git a/src/Helpers/File.js b/src/Helpers/File.js index 12d1542..3e529f1 100644 --- a/src/Helpers/File.js +++ b/src/Helpers/File.js @@ -23,15 +23,16 @@ import { } from 'node:fs' import { lookup } from 'mime-types' +import { pathToFileURL } from 'node:url' import { randomBytes } from 'node:crypto' import { isAbsolute, parse, sep } from 'node:path' +import { Path } from '#src/Helpers/Path' import { Json } from '#src/Helpers/Json' import { Debug } from '#src/Helpers/Debug' import { Parser } from '#src/Helpers/Parser' import { Options } from '#src/Helpers/Options' import { NotFoundFileException } from '#src/Exceptions/NotFoundFileException' -import { Path } from '#src/Helpers/Path' export class File { /** @@ -238,6 +239,7 @@ export class File { name: this.name, base: this.base, path: this.path, + href: this.href, mime: this.mime, createdAt: this.createdAt, accessedAt: this.accessedAt, @@ -682,6 +684,7 @@ export class File { this.name = buffer.toString('base64').replace(/[^a-zA-Z0-9]/g, '') this.base = this.name + this.extension this.path = this.dir + '/' + this.base + this.href = pathToFileURL(this.path).href return } diff --git a/src/index.d.ts b/src/index.d.ts index 65b69fc..7851f39 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -170,6 +170,8 @@ export declare class File { public base: string public path: string + + public href: string public isCopy: boolean