Commit c7ef5eaccc40a7fb5d3bc73c57137c7dda91e7ad
1 parent
efa2c548d6
Exists in
master
Ubah 0 di depan menjadi pada nama terminal baru saat pembuatan downline baru jika phone number
Showing 3 changed files with 17 additions and 6 deletions Side-by-side Diff
lib/command-handler/adddownline.js
... | ... | @@ -49,6 +49,7 @@ function execute(tokens, params, cb) { |
49 | 49 | coreParams.generate_password = 1; |
50 | 50 | } |
51 | 51 | |
52 | + /* | |
52 | 53 | if (typeof coreParams.new_terminal_name === 'string' && coreParams.new_terminal_name.indexOf('@') < 0) { |
53 | 54 | let suffix = ''; |
54 | 55 | if (common.isPhoneNumber(coreParams.new_terminal_name)) { |
... | ... | @@ -64,6 +65,11 @@ function execute(tokens, params, cb) { |
64 | 65 | } |
65 | 66 | |
66 | 67 | coreapi(coreEndpoint, coreParams, 'GET', cb); |
68 | + */ | |
69 | + | |
70 | + if (typeof coreParams.new_terminal_name === 'string' && common.isPhoneNumber(coreParams.new_terminal_name) && coreParams.new_terminal_name.indexOf('0') === 0) { | |
71 | + coreParams.new_terminal_name = coreParams.new_terminal_name.replace(/^0/, '62'); | |
72 | + } | |
67 | 73 | } |
68 | 74 | |
69 | 75 | module.exports = execute; |
70 | 76 | \ No newline at end of file |
lib/common.js
test/common.js
... | ... | @@ -17,17 +17,22 @@ describe('#common', () => { |
17 | 17 | |
18 | 18 | describe('#isPhoneNumber', () => { |
19 | 19 | it('should detect correctly', () => { |
20 | - common.isPhoneNumber('0818').should.be.ok(); | |
21 | - common.isPhoneNumber('62818').should.be.ok(); | |
22 | - common.isPhoneNumber('+62818').should.be.ok(); | |
20 | + common.isPhoneNumber('0818').should.not.be.ok(); | |
21 | + common.isPhoneNumber('62818').should.not.be.ok(); | |
22 | + common.isPhoneNumber('+62818').should.not.be.ok(); | |
23 | + | |
24 | + common.isPhoneNumber('081808180').should.be.ok(); | |
25 | + common.isPhoneNumber('62818818').should.be.ok(); | |
26 | + common.isPhoneNumber('+62818818').should.be.ok(); | |
27 | + | |
23 | 28 | common.isPhoneNumber('ada').should.not.be.ok(); |
24 | 29 | }); |
25 | 30 | }); |
26 | 31 | |
27 | 32 | describe('#indonesiaIntlNumberToZeroPrefix', () => { |
28 | 33 | it('should transform correctly', () => { |
29 | - common.indonesiaIntlNumberToZeroPrefix('+62818').should.equal('0818'); | |
30 | - common.indonesiaIntlNumberToZeroPrefix('0818').should.equal('0818'); | |
34 | + common.indonesiaIntlNumberToZeroPrefix('+6281812341234').should.equal('081812341234', '+6281812341234'); | |
35 | + common.indonesiaIntlNumberToZeroPrefix('081808180').should.equal('081808180', '081808180'); | |
31 | 36 | common.indonesiaIntlNumberToZeroPrefix('ada').should.equal('ada'); |
32 | 37 | }); |
33 | 38 | }) |