提交 c7bd919b 编写于 作者: ruiruibupt's avatar ruiruibupt

code clean

上级 915e54a7
......@@ -68,7 +68,7 @@ import {
isContactId,
isRoomId,
padchatDecode,
pureUserName,
stripBugChatroomId,
} from './pure-function-helpers/'
import { log } from '../config'
......@@ -997,7 +997,7 @@ export class PadchatRpc extends EventEmitter {
if (!result || result.status !== 0) {
throw Error('WXCreateChatRoom , stranger,error! canot get result from websocket server')
}
return pureUserName(result.user_name)
return stripBugChatroomId(result.user_name)
}
// TODO: check any
......
import test from 'blue-tape'
import {
pureUserName,
stripBugChatroomId,
} from './compatible-wei'
test('pureUserName()', async t => {
test('stripBugChatroomId()', async t => {
const RAW_USER_NAME_1 = '\n\u00135907139882@chatroom'
const USER_NAME_1 = '5907139882@chatroom'
const RAW_USER_NAME_2 = '\n\u001412558026334@chatroom'
const USER_NAME_2 = '12558026334@chatroom'
t.equal(pureUserName(RAW_USER_NAME_1) , USER_NAME_1, 'should return pure user_name for RAW_USER_NAME_1')
t.equal(pureUserName(RAW_USER_NAME_2) , USER_NAME_2, 'should return pure user_name for RAW_USER_NAME_2')
t.equal(pureUserName(undefined) , '', 'should return empty string for undifined')
t.equal(stripBugChatroomId(RAW_USER_NAME_1) , USER_NAME_1, 'should return pure user_name for RAW_USER_NAME_1')
t.equal(stripBugChatroomId(RAW_USER_NAME_2) , USER_NAME_2, 'should return pure user_name for RAW_USER_NAME_2')
t.equal(stripBugChatroomId(undefined) , '', 'should return empty string for undifined')
})
......@@ -4,7 +4,7 @@
/**
* WXCreateChatRoom() will get dirty chatroom Id.
* function pureUserName can get a clean chatroom Id.
* function stripBugChatroomId can get a clean chatroom Id.
* https://github.com/lijiarui/wechaty-puppet-padchat/issues/62
*
* WXCreateChatRoom result:
......@@ -12,7 +12,7 @@
* BUG compitable: "\n\u00135907139882@chatroom" -> "5907139882@chatroom"
* BUG compitable: "\n\u001412558026334@chatroom" -> "12558026334@chatroom"
*/
export function pureUserName(id?: string) {
export function stripBugChatroomId(id?: string) {
if (!id) {
return ''
}
......
......@@ -12,6 +12,7 @@
*
*/
export * from './compatible-wei'
export * from './contact-raw-payload-parser'
export * from './file-box-to-qrcode'
export * from './friendship-event-message-parser'
......@@ -24,4 +25,3 @@ export * from './room-event-leave-message-parser'
export * from './room-event-topic-message-parser'
export * from './room-raw-payload-parser'
export * from './split-name'
export * from './compatible-wei'
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册