Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion packages/abbreviation/src/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ function insertHref(node: AbbreviationNode, text: string) {
if (urlRegex.test(text)) {
href = text;
if (!/\w+:/.test(href) && !href.startsWith('//')) {
href = `http://${href}`;
href = `https://${href}`;
}
} else if (emailRegex.test(text)) {
href = `mailto:${text}`;
Expand Down
6 changes: 3 additions & 3 deletions packages/abbreviation/test/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,22 @@ describe('Convert token abbreviations', () => {

it('href', () => {
equal(parse('a', { href: true, text: 'https://www.google.it' }), '<a href="https://www.google.it">https://www.google.it</a>');
equal(parse('a', { href: true, text: 'www.google.it' }), '<a href="http://www.google.it">www.google.it</a>');
equal(parse('a', { href: true, text: 'www.google.it' }), '<a href="https://www.google.it">www.google.it</a>');
equal(parse('a', { href: true, text: 'google.it' }), '<a href="">google.it</a>');
equal(parse('a', { href: true, text: 'test here' }), '<a href="">test here</a>');
equal(parse('a', { href: true, text: 'test@domain.com' }), '<a href="mailto:test@domain.com">test@domain.com</a>');
equal(parse('a', { href: true, text: 'test here test@domain.com' }), '<a href="">test here test@domain.com</a>');
equal(parse('a', { href: true, text: 'test here www.domain.com' }), '<a href="">test here www.domain.com</a>');

equal(parse('a[href=]', { href: true, text: 'https://www.google.it' }), '<a href="https://www.google.it">https://www.google.it</a>');
equal(parse('a[href=]', { href: true, text: 'www.google.it' }), '<a href="http://www.google.it">www.google.it</a>');
equal(parse('a[href=]', { href: true, text: 'www.google.it' }), '<a href="https://www.google.it">www.google.it</a>');
equal(parse('a[href=]', { href: true, text: 'google.it' }), '<a href="">google.it</a>');
equal(parse('a[href=]', { href: true, text: 'test here' }), '<a href="">test here</a>');
equal(parse('a[href=]', { href: true, text: 'test@domain.com' }), '<a href="mailto:test@domain.com">test@domain.com</a>');
equal(parse('a[href=]', { href: true, text: 'test here test@domain.com' }), '<a href="">test here test@domain.com</a>');
equal(parse('a[href=]', { href: true, text: 'test here www.domain.com' }), '<a href="">test here www.domain.com</a>');
equal(parse('a[class=here]', { href: true, text: 'test@domain.com' }), '<a class="here", href="mailto:test@domain.com">test@domain.com</a>');
equal(parse('a.here', { href: true, text: 'www.domain.com' }), '<a class="here", href="http://www.domain.com">www.domain.com</a>');
equal(parse('a.here', { href: true, text: 'www.domain.com' }), '<a class="here", href="https://www.domain.com">www.domain.com</a>');
equal(parse('a[class=here]', { href: true, text: 'test here test@domain.com' }), '<a class="here", href="">test here test@domain.com</a>');
equal(parse('a.here', { href: true, text: 'test here www.domain.com' }), '<a class="here", href="">test here www.domain.com</a>');

Expand Down
4 changes: 2 additions & 2 deletions src/snippets/html.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"a": "a[href]",
"a:blank": "a[href='http://${0}' target='_blank' rel='noopener noreferrer']",
"a:link": "a[href='http://${0}']",
"a:blank": "a[href='https://${0}' target='_blank' rel='noopener noreferrer']",
"a:link": "a[href='https://${0}']",
"a:mail": "a[href='mailto:${0}']",
"a:tel": "a[href='tel:+${0}']",
"abbr": "abbr[title]",
Expand Down
2 changes: 1 addition & 1 deletion test/expand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ describe('Expand Abbreviation', () => {
});

it('wrap with abbreviation href', () => {
equal(expand('a', { text: ['www.google.it'] }), '<a href="http://www.google.it">www.google.it</a>');
equal(expand('a', { text: ['www.google.it'] }), '<a href="https://www.google.it">www.google.it</a>');
equal(expand('a', { text: ['then www.google.it'] }), '<a href="">then www.google.it</a>');
equal(expand('a', { text: ['www.google.it'], options: { 'markup.href': false } }), '<a href="">www.google.it</a>');

Expand Down
Loading