Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/core/link.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(function() {
'use strict';

var REGEX_BOOKMARK_SCHEME = /^#.*/i;
var REGEX_EMAIL_SCHEME = /^[a-z0-9\u0430-\u044F\._-]+@/i;
var REGEX_URI_SCHEME = /^(?:[a-z][a-z0-9+\-.]*)\:|^\//i;

Expand Down Expand Up @@ -214,8 +215,9 @@
},

/**
* Checks if the URI has an '@' symbol. If it does and the URI looks like an email
* and doesn't have 'mailto:', 'mailto:' is added to the URI.
* Checks if the URI begins with a '#' symbol to determine if it's an on page bookmark.
* If it doesn't, it then checks if the URI has an '@' symbol. If it does and the URI
* looks like an email and doesn't have 'mailto:', 'mailto:' is added to the URI.
* If it doesn't and the URI doesn't have a scheme, the default 'http' scheme with
* hierarchical path '//' is added to the URI.
*
Expand All @@ -227,7 +229,9 @@
* @return {String} The URI updated with the protocol.
*/
_getCompleteURI: function(URI) {
if (REGEX_EMAIL_SCHEME.test(URI)) {
if (REGEX_BOOKMARK_SCHEME.test(URI)) {
return URI;
} else if (REGEX_EMAIL_SCHEME.test(URI)) {
URI = 'mailto:' + URI;
} else if (!REGEX_URI_SCHEME.test(URI)) {
URI = this.appendProtocol ? 'http://' + URI : URI;
Expand Down