@bgord/tools 1.1.14 → 1.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/filename.vo.d.ts +2 -0
- package/dist/filename.vo.js +4 -0
- package/dist/mime.vo.js +2 -3
- package/package.json +1 -1
- package/src/filename.vo.ts +5 -0
- package/src/mime.vo.ts +2 -4
package/dist/filename.vo.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type BasenameType } from "./basename.vo";
|
|
2
2
|
import { type ExtensionType } from "./extension.vo";
|
|
3
3
|
import { FilenameAffixStrategy, type FilenameAffixType } from "./filename-affix.vo";
|
|
4
|
+
import { Mime } from "./mime.vo";
|
|
4
5
|
export declare class Filename {
|
|
5
6
|
private readonly basename;
|
|
6
7
|
private readonly extension;
|
|
@@ -11,6 +12,7 @@ export declare class Filename {
|
|
|
11
12
|
get(): string;
|
|
12
13
|
getBasename(): BasenameType;
|
|
13
14
|
getExtension(): ExtensionType;
|
|
15
|
+
getMime(): Mime;
|
|
14
16
|
withExtension(extension: ExtensionType): Filename;
|
|
15
17
|
withBasename(basename: BasenameType): Filename;
|
|
16
18
|
withAffix(candidate: string, strategy: FilenameAffixStrategy): Filename;
|
package/dist/filename.vo.js
CHANGED
|
@@ -2,6 +2,7 @@ import { Basename } from "./basename.vo";
|
|
|
2
2
|
import { Extension } from "./extension.vo";
|
|
3
3
|
import { FilenameAffix, FilenameAffixStrategy } from "./filename-affix.vo";
|
|
4
4
|
import { FilenameFromString } from "./filename-from-string.vo";
|
|
5
|
+
import { Mime } from "./mime.vo";
|
|
5
6
|
export class Filename {
|
|
6
7
|
basename;
|
|
7
8
|
extension;
|
|
@@ -28,6 +29,9 @@ export class Filename {
|
|
|
28
29
|
getExtension() {
|
|
29
30
|
return this.extension;
|
|
30
31
|
}
|
|
32
|
+
getMime() {
|
|
33
|
+
return Mime.fromExtension(this.extension);
|
|
34
|
+
}
|
|
31
35
|
withExtension(extension) {
|
|
32
36
|
return new Filename(this.basename, extension);
|
|
33
37
|
}
|
package/dist/mime.vo.js
CHANGED
|
@@ -10,12 +10,11 @@ export class Mime {
|
|
|
10
10
|
this.subtype = subtype;
|
|
11
11
|
}
|
|
12
12
|
static fromString(candidate) {
|
|
13
|
-
const { type, subtype } = MimeValue.parse(candidate);
|
|
13
|
+
const { type, subtype } = MimeValue.parse(candidate.split(";")[0].trim());
|
|
14
14
|
return new Mime(type, subtype);
|
|
15
15
|
}
|
|
16
16
|
static fromExtension(extension) {
|
|
17
|
-
|
|
18
|
-
return new Mime(type, subtype);
|
|
17
|
+
return Mime.fromString(String(mime.contentType(extension)));
|
|
19
18
|
}
|
|
20
19
|
isSatisfiedBy(another) {
|
|
21
20
|
if (!(this.type === another.type || this.type === "*"))
|
package/package.json
CHANGED
package/src/filename.vo.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Basename, type BasenameType } from "./basename.vo";
|
|
|
2
2
|
import { Extension, type ExtensionType } from "./extension.vo";
|
|
3
3
|
import { FilenameAffix, FilenameAffixStrategy, type FilenameAffixType } from "./filename-affix.vo";
|
|
4
4
|
import { FilenameFromString } from "./filename-from-string.vo";
|
|
5
|
+
import { Mime } from "./mime.vo";
|
|
5
6
|
|
|
6
7
|
export class Filename {
|
|
7
8
|
private constructor(
|
|
@@ -35,6 +36,10 @@ export class Filename {
|
|
|
35
36
|
return this.extension;
|
|
36
37
|
}
|
|
37
38
|
|
|
39
|
+
getMime(): Mime {
|
|
40
|
+
return Mime.fromExtension(this.extension);
|
|
41
|
+
}
|
|
42
|
+
|
|
38
43
|
withExtension(extension: ExtensionType): Filename {
|
|
39
44
|
return new Filename(this.basename, extension);
|
|
40
45
|
}
|
package/src/mime.vo.ts
CHANGED
|
@@ -11,15 +11,13 @@ export class Mime {
|
|
|
11
11
|
) {}
|
|
12
12
|
|
|
13
13
|
static fromString(candidate: string): Mime {
|
|
14
|
-
const { type, subtype } = MimeValue.parse(candidate);
|
|
14
|
+
const { type, subtype } = MimeValue.parse(candidate.split(";")[0].trim());
|
|
15
15
|
|
|
16
16
|
return new Mime(type, subtype);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
static fromExtension(extension: ExtensionType): Mime {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return new Mime(type, subtype);
|
|
20
|
+
return Mime.fromString(String(mime.contentType(extension)));
|
|
23
21
|
}
|
|
24
22
|
|
|
25
23
|
isSatisfiedBy(another: Mime): boolean {
|