Fixes #3344 - Allow mailto links in knowledge base (KB) and email signatures
This commit is contained in:
parent
876c0b18fd
commit
ff00eb07fb
2 changed files with 51 additions and 3 deletions
|
@ -21,10 +21,10 @@ class App.UiElement.richtext.additions.RichTextToolPopupLink extends App.UiEleme
|
||||||
ensureProtocol: (input) ->
|
ensureProtocol: (input) ->
|
||||||
input = input.trim()
|
input = input.trim()
|
||||||
|
|
||||||
if !input.match(/^\S+\:\/\//) and input[0] isnt '/'
|
if @isWithProtocol(input) || @isRelativePath(input) || @isMailto(input)
|
||||||
'http://' + input
|
|
||||||
else
|
|
||||||
input
|
input
|
||||||
|
else
|
||||||
|
'http://' + input
|
||||||
|
|
||||||
apply: (callback) ->
|
apply: (callback) ->
|
||||||
input = @el.find('input').val()
|
input = @el.find('input').val()
|
||||||
|
@ -57,3 +57,12 @@ class App.UiElement.richtext.additions.RichTextToolPopupLink extends App.UiEleme
|
||||||
switch @selection.type
|
switch @selection.type
|
||||||
when 'existing'
|
when 'existing'
|
||||||
$(@selection.dom).contents().unwrap()
|
$(@selection.dom).contents().unwrap()
|
||||||
|
|
||||||
|
isWithProtocol: (input) ->
|
||||||
|
/^\S+\:\/\//.test(input)
|
||||||
|
|
||||||
|
isMailto: (input) ->
|
||||||
|
/^mailto\:\S+@\S/.test(input)
|
||||||
|
|
||||||
|
isRelativePath: (input) ->
|
||||||
|
input[0] is '/'
|
||||||
|
|
|
@ -20,6 +20,45 @@ RSpec.describe 'Knowledge Base Locale Answer Edit', type: :system, authenticated
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'add weblink' do
|
||||||
|
def open_editor_and_add_link(input)
|
||||||
|
visit "#knowledge_base/#{knowledge_base.id}/locale/#{primary_locale.system_locale.locale}/answer/#{draft_answer.id}/edit"
|
||||||
|
|
||||||
|
sleep 3 # wait for popover killer to pass
|
||||||
|
|
||||||
|
find('a[data-action="link"]').click
|
||||||
|
|
||||||
|
within('.popover-content') do
|
||||||
|
find('input').fill_in with: input
|
||||||
|
find('[type=submit]').click
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'allows mailto links' do
|
||||||
|
open_editor_and_add_link 'mailto:test@example.com'
|
||||||
|
|
||||||
|
expect(page).to have_selector('a[href="mailto:test@example.com"]')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'allows link with a protocol' do
|
||||||
|
open_editor_and_add_link 'protocol://example.org'
|
||||||
|
|
||||||
|
expect(page).to have_selector('a[href="protocol://example.org"]')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'allows relative link' do
|
||||||
|
open_editor_and_add_link '/path'
|
||||||
|
|
||||||
|
expect(page).to have_selector('a[href="/path"]')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'allows non-protocol URL and prepends default protocol' do
|
||||||
|
open_editor_and_add_link 'example.com'
|
||||||
|
|
||||||
|
expect(page).to have_selector('a[href="http://example.com"]')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'embedded video' do
|
context 'embedded video' do
|
||||||
|
|
||||||
it 'has adding functionality' do
|
it 'has adding functionality' do
|
||||||
|
|
Loading…
Reference in a new issue