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

过滤private field不翻译 #151

Merged
merged 2 commits into from
Nov 8, 2019

Conversation

AtarisMio
Copy link
Contributor

fix #33

@hufeng
Copy link
Member

hufeng commented Nov 6, 2019

@hsiaosiyuan0 @sunchuanleihit please help review

@@ -62,21 +64,30 @@ export async function toBeanClass(
if (typeDef.fields[fieldName].isArray) {
filedType = typeDef.fields[fieldName].elementType.name;
}
const regex = new RegExp(
`^(get|set${fieldName.slice(0, 1).toUpperCase()}${fieldName.slice(1)})$`,
Copy link
Contributor

@hsiaosiyuan0 hsiaosiyuan0 Nov 6, 2019

Choose a reason for hiding this comment

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

Please consider below test case:

const fieldName = 'name';
const regex = new RegExp(`^(get|set${fieldName.slice(0, 1).toUpperCase()}${fieldName.slice(1)})$`);
regex.test('getName'); // expect `true` but got `false`

and then if we just want to capitalize the first character I think the better way is using fieldName[0].toUpperCase() directly, it's safe since fieldName can never be an empty string

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, sorry. It's a typo. Please review it again.

Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM. It's up to @hufeng 😏

Copy link
Member

Choose a reason for hiding this comment

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

OK

@hufeng hufeng merged commit 783df6e into apache:master Nov 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

翻译师:私有变量应该过滤,不进行翻译
3 participants