Skip to content

Commit

Permalink
fix: #608 link protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
JiHong88 committed Jan 27, 2021
1 parent d96b2c1 commit 5b098d7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/plugins/modules/_anchor.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,9 @@ export default {
setLinkPreview: function (context, protocol, e) {
const preview = context.preview;
const value = typeof e === 'string' ? e : e.target.value.trim();
const linkHTTP = value.indexOf('://') === -1 && value.indexOf('#') !== 0;
context.linkValue = preview.textContent = !value ? '' : (protocol && linkHTTP) ? protocol + value : linkHTTP ? '/' + value : value;
const reservedProtocol = /^(mailto\:|https*\:\/\/)/.test(value);
const sameProtocol = !protocol ? false : this._w.RegExp('^' + value.substr(0, protocol.length)).test(protocol);
context.linkValue = preview.textContent = !value ? '' : (protocol && !reservedProtocol && !sameProtocol) ? protocol + value : value;

if (value.indexOf('#') === 0) {
context.bookmark.style.display = 'block';
Expand Down

0 comments on commit 5b098d7

Please sign in to comment.