Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Codescanning alerts #11159

Merged
merged 2 commits into from
Mar 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the tests!

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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonder why this went up for such a small change?

},
{
"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