mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-11-26 07:19:23 +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 { UserHelper } from "../helpers/UserHelper";
|
||||||
import { User, UserPageStatus } from "../entities/User";
|
import { User, UserPageStatus } from "../entities/User";
|
||||||
import { AccountImage, AccountImageVisibilityLevel } from "../entities/AccountImage";
|
import { AccountImage, AccountImageVisibilityLevel } from "../entities/AccountImage";
|
||||||
|
import { fixEncoding } from "../utils/StringUtils";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User information controller
|
* User information controller
|
||||||
@ -50,8 +51,8 @@ export class UserController {
|
|||||||
private static UserToAPI(user : User, handler: RequestHandler) : Object {
|
private static UserToAPI(user : User, handler: RequestHandler) : Object {
|
||||||
return {
|
return {
|
||||||
"userID": user.id,
|
"userID": user.id,
|
||||||
"firstName": user.firstName,
|
"firstName": fixEncoding(user.firstName),
|
||||||
"lastName": user.lastName,
|
"lastName": fixEncoding(user.lastName),
|
||||||
"publicPage": user.pageStatus == UserPageStatus.PUBLIC,
|
"publicPage": user.pageStatus == UserPageStatus.PUBLIC,
|
||||||
"openPage": user.pageStatus == UserPageStatus.OPEN,
|
"openPage": user.pageStatus == UserPageStatus.OPEN,
|
||||||
"virtualDirectory": user.virtualDirectory,
|
"virtualDirectory": user.virtualDirectory,
|
||||||
|
@ -13,3 +13,12 @@
|
|||||||
export function checkMail(emailAddress: string): boolean {
|
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);
|
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