Skip to content

Commit

Permalink
fix: add getObjectUrl alias to generateObjectUrl (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 authored Oct 7, 2023
1 parent 2df149f commit 0cfa089
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/OSSObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,13 @@ export class OSSObject extends OSSBaseClient implements IObjectSimple {
return urlObject.toString();
}

/**
* @alias generateObjectUrl
*/
getObjectUrl(name: string, baseUrl?: string) {
return this.generateObjectUrl(name, baseUrl);
}

/**
* @param policy specifies the validity of the fields in the request.
*
Expand Down
4 changes: 3 additions & 1 deletion test/OSSObject.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2221,7 +2221,7 @@ describe('test/OSSObject.test.ts', () => {
});
});

describe('generateObjectUrl()', () => {
describe('generateObjectUrl() & getObjectUrl()', () => {
it('should return object url', () => {
let name = 'test.js';
let url = ossObject.generateObjectUrl(name);
Expand All @@ -2230,8 +2230,10 @@ describe('test/OSSObject.test.ts', () => {
name = '/foo/bar/a%2Faa/test&+-123~!.js';
url = ossObject.generateObjectUrl(name, 'https://foo.com');
assert.equal(url, 'https://foo.com/foo/bar/a%252Faa/test%26%2B-123~!.js');
assert.equal(ossObject.generateObjectUrl(name, 'https://foo.com'), url);
const url2 = ossObject.generateObjectUrl(name, 'https://foo.com/');
assert.equal(url2, 'https://foo.com/foo/bar/a%252Faa/test%26%2B-123~!.js');
assert.equal(ossObject.generateObjectUrl(name, 'https://foo.com/'), url2);
});
});

Expand Down

0 comments on commit 0cfa089

Please sign in to comment.