mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-11-22 13:29:22 +00:00
Fix encoding issue
This commit is contained in:
parent
0cb6688884
commit
17f70b956b
@ -2,6 +2,7 @@ import { RequestHandler } from "../entities/RequestHandler";
|
||||
import { UserHelper } from "../helpers/UserHelper";
|
||||
import { User, UserPageStatus } from "../entities/User";
|
||||
import { AccountImage, AccountImageVisibilityLevel } from "../entities/AccountImage";
|
||||
import { fixEncoding } from "../utils/StringUtils";
|
||||
|
||||
/**
|
||||
* User information controller
|
||||
@ -50,8 +51,8 @@ export class UserController {
|
||||
private static UserToAPI(user : User, handler: RequestHandler) : Object {
|
||||
return {
|
||||
"userID": user.id,
|
||||
"firstName": user.firstName,
|
||||
"lastName": user.lastName,
|
||||
"firstName": fixEncoding(user.firstName),
|
||||
"lastName": fixEncoding(user.lastName),
|
||||
"publicPage": user.pageStatus == UserPageStatus.PUBLIC,
|
||||
"openPage": user.pageStatus == UserPageStatus.OPEN,
|
||||
"virtualDirectory": user.virtualDirectory,
|
||||
|
@ -13,3 +13,12 @@
|
||||
export function checkMail(emailAddress: string): boolean {
|
||||
return (emailAddress.match(/^[a-zA-Z0-9_.]+@[a-zA-Z0-9-.]{1,}[.][a-zA-Z]{2,8}$/) === null ? false : true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix text encoding
|
||||
*
|
||||
* @param input Input string
|
||||
*/
|
||||
export function fixEncoding(input : string) : string {
|
||||
return Buffer.from(input, "latin1").toString("utf-8");
|
||||
}
|
Loading…
Reference in New Issue
Block a user