Skip to content

Commit

Permalink
fix: Codescanning alerts (#11159)
Browse files Browse the repository at this point in the history
  • Loading branch information
stocaaro authored and cshfang committed Apr 7, 2023
1 parent 79eaf52 commit 0b00cae
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
21 changes: 21 additions & 0 deletions packages/core/__tests__/I18n-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,26 @@ describe('I18n test', () => {
cn: {},
};
});

test('multi-call putVocabulariesForLanguage results in correct get result', () => {
const i18n = new I18n(null);

i18n.putVocabulariesForLanguage('cn', {
hello: '你好',
exciting: '+1s',
stable: 'x',
});

i18n.putVocabulariesForLanguage('cn', {
exciting: '+2s',
});

expect(i18n.getByLanguage('exciting', 'cn')).toEqual('+2s');
expect(i18n.getByLanguage('stable', 'cn')).toEqual('x');

i18n._dict = {
cn: {},
};
});
});
});
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"name": "Core (I18n)",
"path": "./lib-esm/index.js",
"import": "{ I18n }",
"limit": "2 kB"
"limit": "2.1 kB"
},
{
"name": "Core (Logger)",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/I18n/I18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export class I18n {
if (!lang_dict) {
lang_dict = this._dict[language] = {};
}
Object.assign(lang_dict, vocabularies);
this._dict[language] = { ...lang_dict, ...vocabularies };
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class AmazonAIIdentifyPredictionsProvider extends AbstractIdentifyPredict
Storage.get(source.key, storageConfig)
.then((url: string) => {
const parser =
/https:\/\/([a-zA-Z0-9%-_.]+)\.s3\.[A-Za-z0-9%-._~]+\/([a-zA-Z0-9%-._~/]+)\?/;
/https:\/\/([a-zA-Z0-9%\-_.]+)\.s3\.[A-Za-z0-9%\-._~]+\/([a-zA-Z0-9%\-._~/]+)\?/;
const parsedURL = url.match(parser);
if (parsedURL.length < 3) rej('Invalid S3 key was given.');
res({
Expand Down

0 comments on commit 0b00cae

Please sign in to comment.