Fixed issue #991 - Tel Protocol Link for Telephone and Mobile.
This commit is contained in:
parent
d1b50e0ed2
commit
9ec4be24f3
2 changed files with 36 additions and 5 deletions
|
@ -124,10 +124,11 @@ class App.Utils
|
|||
@linkify: (string) ->
|
||||
window.linkify(string)
|
||||
|
||||
# htmlEscapedAndLinkified = App.Utils.linkify(rawText)
|
||||
# htmlEscapedAndPhoneified = App.Utils.phoneify(rawText)
|
||||
@phoneify: (string) ->
|
||||
string = string.replace(/\s+/g, '')
|
||||
"tel://#{encodeURIComponent(string)}"
|
||||
string = string.replace(/[^0-9,\+,#,\*]+/g, '')
|
||||
.replace(/(.)\+/, '$1')
|
||||
"tel:#{string}"
|
||||
|
||||
# wrappedText = App.Utils.wrap(rawText, maxLineLength)
|
||||
@wrap: (ascii, max = 82) ->
|
||||
|
|
|
@ -201,12 +201,42 @@ test("html2text", function() {
|
|||
test("phoneify", function() {
|
||||
|
||||
var source = "+1 123 123 123-123"
|
||||
var should = 'tel://%2B1123123123-123'
|
||||
var should = 'tel:+1123123123123'
|
||||
var result = App.Utils.phoneify(source)
|
||||
equal(result, should, source)
|
||||
|
||||
source = "+1 123 123 A 123-123<>"
|
||||
should = 'tel://%2B1123123A123-123%3C%3E'
|
||||
should = 'tel:+1123123123123'
|
||||
result = App.Utils.phoneify(source)
|
||||
equal(result, should, source)
|
||||
|
||||
source = "+1 (123) 123 123-123"
|
||||
should = 'tel:+1123123123123'
|
||||
result = App.Utils.phoneify(source)
|
||||
equal(result, should, source)
|
||||
|
||||
source = "+1 (123) 123 1#23-123"
|
||||
should = 'tel:+11231231#23123'
|
||||
result = App.Utils.phoneify(source)
|
||||
equal(result, should, source)
|
||||
|
||||
source = "+1 (123) 12*3 1#23-123"
|
||||
should = 'tel:+112312*31#23123'
|
||||
result = App.Utils.phoneify(source)
|
||||
equal(result, should, source)
|
||||
|
||||
source = "+1 (123) 12+3"
|
||||
should = 'tel:+1123123'
|
||||
result = App.Utils.phoneify(source)
|
||||
equal(result, should, source)
|
||||
|
||||
source = "+1 (123) 123 "
|
||||
should = 'tel:+1123123'
|
||||
result = App.Utils.phoneify(source)
|
||||
equal(result, should, source)
|
||||
|
||||
source = " +1 (123) 123 "
|
||||
should = 'tel:+1123123'
|
||||
result = App.Utils.phoneify(source)
|
||||
equal(result, should, source)
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue