Skip to content

Commit

Permalink
Fix autolink with scheme test
Browse files Browse the repository at this point in the history
  • Loading branch information
lqez committed Jan 12, 2016
1 parent ee3be86 commit 4a9f628
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/js/base/module/AutoLink.js
Expand Up @@ -9,6 +9,7 @@ define([
var self = this;

var linkPattern = /^(https?:\/\/|ssh:\/\/|ftp:\/\/|file:\/|www\.|(?:mailto:)?[A-Z0-9._%+-]+@)(.+)$/i;
var schemePattern = /^([a-z]+:)(\/\/)?/i;

this.events = {
'summernote.keyup': function (we, e) {
Expand Down Expand Up @@ -47,7 +48,8 @@ define([
};

this.nodeFromKeyword = function (keyword) {
return $('<a />').html(keyword).attr('href', keyword)[0];
var link = schemePattern.test(keyword) ? keyword : 'http://' + keyword;
return $('<a />').html(keyword).attr('href', link)[0];
};

this.handleKeydown = function (e) {
Expand Down

0 comments on commit 4a9f628

Please sign in to comment.