From 3f733761f943fe8c61d3e75450588d614571a937 Mon Sep 17 00:00:00 2001 From: "Mohit.Tokas" Date: Sat, 7 Jun 2025 13:41:42 +0530 Subject: [PATCH] feat: change default URL protocol from http:// to https:// - Updated insertHref function to use https:// instead of http:// for URLs without protocol - Updated HTML snippets (a:blank, a:link) to use https:// by default - Updated all related tests to expect https:// protocol - Addresses modern web standards where most websites use SSL encryption Fixes the issue where Emmet automatically adds http:// protocol when wrapping URLs with anchor tags, now defaults to the more secure https:// protocol. --- packages/abbreviation/src/convert.ts | 2 +- packages/abbreviation/test/convert.ts | 6 +++--- src/snippets/html.json | 4 ++-- test/expand.ts | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/abbreviation/src/convert.ts b/packages/abbreviation/src/convert.ts index 93840556..30b9efab 100644 --- a/packages/abbreviation/src/convert.ts +++ b/packages/abbreviation/src/convert.ts @@ -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}`; diff --git a/packages/abbreviation/test/convert.ts b/packages/abbreviation/test/convert.ts index 245b2ca4..e0e42a26 100644 --- a/packages/abbreviation/test/convert.ts +++ b/packages/abbreviation/test/convert.ts @@ -58,7 +58,7 @@ describe('Convert token abbreviations', () => { it('href', () => { equal(parse('a', { href: true, text: 'https://www.google.it' }), 'https://www.google.it'); - equal(parse('a', { href: true, text: 'www.google.it' }), 'www.google.it'); + equal(parse('a', { href: true, text: 'www.google.it' }), 'www.google.it'); equal(parse('a', { href: true, text: 'google.it' }), 'google.it'); equal(parse('a', { href: true, text: 'test here' }), 'test here'); equal(parse('a', { href: true, text: 'test@domain.com' }), 'test@domain.com'); @@ -66,14 +66,14 @@ describe('Convert token abbreviations', () => { equal(parse('a', { href: true, text: 'test here www.domain.com' }), 'test here www.domain.com'); equal(parse('a[href=]', { href: true, text: 'https://www.google.it' }), 'https://www.google.it'); - equal(parse('a[href=]', { href: true, text: 'www.google.it' }), 'www.google.it'); + equal(parse('a[href=]', { href: true, text: 'www.google.it' }), 'www.google.it'); equal(parse('a[href=]', { href: true, text: 'google.it' }), 'google.it'); equal(parse('a[href=]', { href: true, text: 'test here' }), 'test here'); equal(parse('a[href=]', { href: true, text: 'test@domain.com' }), 'test@domain.com'); equal(parse('a[href=]', { href: true, text: 'test here test@domain.com' }), 'test here test@domain.com'); equal(parse('a[href=]', { href: true, text: 'test here www.domain.com' }), 'test here www.domain.com'); equal(parse('a[class=here]', { href: true, text: 'test@domain.com' }), 'test@domain.com'); - equal(parse('a.here', { href: true, text: 'www.domain.com' }), 'www.domain.com'); + equal(parse('a.here', { href: true, text: 'www.domain.com' }), 'www.domain.com'); equal(parse('a[class=here]', { href: true, text: 'test here test@domain.com' }), 'test here test@domain.com'); equal(parse('a.here', { href: true, text: 'test here www.domain.com' }), 'test here www.domain.com'); diff --git a/src/snippets/html.json b/src/snippets/html.json index fa2a823f..18004aeb 100644 --- a/src/snippets/html.json +++ b/src/snippets/html.json @@ -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]", diff --git a/test/expand.ts b/test/expand.ts index 29bf03dd..6567b830 100644 --- a/test/expand.ts +++ b/test/expand.ts @@ -171,7 +171,7 @@ describe('Expand Abbreviation', () => { }); it('wrap with abbreviation href', () => { - equal(expand('a', { text: ['www.google.it'] }), 'www.google.it'); + equal(expand('a', { text: ['www.google.it'] }), 'www.google.it'); equal(expand('a', { text: ['then www.google.it'] }), 'then www.google.it'); equal(expand('a', { text: ['www.google.it'], options: { 'markup.href': false } }), 'www.google.it');