Skip to content

Commit e0855ad

Browse files
authored
Merge pull request #33 from AssemblyAI/E07417BDFEA3614F5967B1520F8B2F61
Release 4.2.2
2 parents a88f2d4 + 458a085 commit e0855ad

File tree

5 files changed

+45
-12
lines changed

5 files changed

+45
-12
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
# Changelog
22

3+
## [4.2.2] - 2024-01-29
4+
5+
### Changed
6+
7+
- Windows paths passed to `client.transcripts.transcribe` and `client.transcripts.submit` will work as expected.
8+
39
## [4.2.1] - 2024-01-23
410

511
### Added
12+
613
- Add `answer_format` to `LemurActionItemsParams` type
714

815
### Changed
16+
917
- Rename `RealtimeService` to `RealtimeTranscriber`, `RealtimeServiceFactory` to `RealtimeTranscriberFactory`, `RealtimeTranscriberFactory.createService()` to `RealtimeTranscriberFactory.transcriber()`. Deprecated aliases are provided for all old types and functions for backwards compatibility.
1018
- Restrict the type for `redact_pii_audio_quality` from `string` to `RedactPiiAudioQuality` an enum string.
1119

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "assemblyai",
3-
"version": "4.2.1",
3+
"version": "4.2.2",
44
"description": "The AssemblyAI JavaScript SDK provides an easy-to-use interface for interacting with the AssemblyAI API, which supports async and real-time transcription, as well as the latest LeMUR models.",
55
"engines": {
66
"node": ">=18"

src/services/transcripts/index.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
SubmitParams,
2222
} from "../..";
2323
import { FileService } from "../files";
24+
import { getPath } from "../../utils/path";
2425

2526
export class TranscriptService
2627
extends BaseService
@@ -249,14 +250,3 @@ export class TranscriptService
249250
);
250251
}
251252
}
252-
253-
function getPath(path: string) {
254-
let url: URL;
255-
try {
256-
url = new URL(path);
257-
if (url.protocol === "file:") return url.pathname;
258-
else return null;
259-
} catch {
260-
return path;
261-
}
262-
}

src/utils/path.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export function getPath(path: string) {
2+
if (path.startsWith("http")) return null;
3+
if (path.startsWith("https")) return null;
4+
if (path.startsWith("file://")) return path.substring(7);
5+
if (path.startsWith("file:")) return path.substring(5);
6+
return path;
7+
}

tests/utils.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import fetchMock from "jest-fetch-mock";
22
import { AssemblyAI } from "../src";
3+
import { getPath } from "../src/utils/path";
34

45
fetchMock.enableMocks();
56

@@ -24,4 +25,31 @@ describe("utils", () => {
2425
fetchMock.mockResponseOnce(JSON.stringify(error), { status: 500 });
2526
await expect(() => assembly.transcripts.get("123")).rejects.toThrow(error);
2627
});
28+
29+
it("should return correct path", () => {
30+
const dict = [
31+
["path/to/file", "path/to/file"],
32+
["/path/to/file", "/path/to/file"],
33+
["./path/to/file", "./path/to/file"],
34+
["C:/path/to/file", "C:/path/to/file"],
35+
["D:/path/to/file", "D:/path/to/file"],
36+
["C:\\path\\to\\file", "C:\\path\\to\\file"],
37+
["D:\\path\\to\\file", "D:\\path\\to\\file"],
38+
["http://example.com", null],
39+
["https://example.com", null],
40+
["file://path/to/file", "path/to/file"],
41+
["file://C:/path/to/file", "C:/path/to/file"],
42+
["file://D:/path/to/file", "D:/path/to/file"],
43+
["file:path/to/file", "path/to/file"],
44+
["file:C:/path/to/file", "C:/path/to/file"],
45+
["file:D:/path/to/file", "D:/path/to/file"],
46+
["file:C:\\path\\to\\file", "C:\\path\\to\\file"],
47+
["file:D:\\path\\to\\file", "D:\\path\\to\\file"],
48+
["file://C:\\path\\to\\file", "C:\\path\\to\\file"],
49+
["file://D:\\path\\to\\file", "D:\\path\\to\\file"],
50+
];
51+
for (const [input, output] of dict) {
52+
expect(getPath(input as string)).toEqual(output);
53+
}
54+
});
2755
});

0 commit comments

Comments
 (0)