Skip to content

Commit 804aa38

Browse files
authored
fix: fix cos error and add test for it (#185)
1 parent f42e3df commit 804aa38

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

__tests__/cos.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,16 @@ describe('Cos', () => {
7979
expect(data).toMatch(/Serverless\sFramework/gi);
8080
});
8181

82+
test('should Cos getObjectUrl success', async () => {
83+
const res = await cos.getObjectUrl({
84+
bucket,
85+
object: 'index.html',
86+
method: 'GET',
87+
});
88+
89+
expect(res).toMatch(/http/);
90+
});
91+
8292
test('should deploy website success', async () => {
8393
const res = await cos.website(websiteInputs);
8494

src/modules/cos/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ export default class Cos {
431431

432432
async getObjectUrl(inputs: CosGetObjectUrlInputs = {}) {
433433
try {
434-
const { Url } = await this.cosClient.getObjectUrl({
434+
const res = await this.cosClient.getObjectUrl({
435435
Bucket: inputs.bucket!,
436436
Region: this.region,
437437
Key: inputs.object!,
@@ -442,7 +442,8 @@ export default class Cos {
442442
// default is sign url
443443
Sign: inputs.sign === false ? false : true,
444444
});
445-
return Url;
445+
// FIXME: Fuck you Cos SDK, res is not an object;
446+
return (res as unknown) as string;
446447
} catch (err) {
447448
throw constructCosError(`API_COS_getObjectUrl`, err);
448449
}

0 commit comments

Comments
 (0)