Skip to content

Commit

Permalink
feat(file): add href property to File class
Browse files Browse the repository at this point in the history
  • Loading branch information
jlenon7 committed May 1, 2022
1 parent 5b45de3 commit 3b19fe9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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 <lenon@athenna.io>",
Expand Down
5 changes: 4 additions & 1 deletion src/Helpers/File.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
/**
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 2 additions & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ export declare class File {
public base: string

public path: string

public href: string

public isCopy: boolean

Expand Down

0 comments on commit 3b19fe9

Please sign in to comment.