Merge "Revert "Auto-link URLs without scheme""
diff --git a/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text.ts b/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text.ts
index c445817..fa2a4ff 100644
--- a/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text.ts
+++ b/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text.ts
@@ -131,31 +131,6 @@
link: '$1',
enabled: true,
};
-
- // Linkify schemeless URLs with proper domain structures.
- this.repoCommentLinks['ALWAYS_LINK_SCHEMELESS'] = {
- // (?<=\s|^|[('":[]) // Ensure the match is preceded by whitespace,
- // // start of line, or one of ( ' " : [
- // ( // Start capture group 1
- // (?: // Start non-capturing domain group
- // [\w-]+\. // Sequence of words/hyphens with dot, e.g. "a-b."
- // )+ // End domain group. Require at least one match
- // [\w-]+ // End with words/hyphens for TLD e.g. "com"
- // (?: // Start optional non-capturing path/query/fragment group
- // [/?#] // Start with one of / ? #
- // [^\s'"]* // Followed by some chars that are not whitespace,
- // // ' or " (to not grab trailing quotes)
- // )? // End optional path/query/fragment group
- // ) // End capture group 1
- // (?=\s|$|[)'"!?.,]) // Ensure the match is followed by whitespace,
- // // end of line, or one of ) ' " ! ? . ,
- match:
- '(?<=\\s|^|[(\'":[])((?:[\\w-]+\\.)+[\\w-]+(?:[/?#][^\\s\'"]*)?)(?=\\s|$|[)\'"!?.,])',
- // Prepend http:// for the link href otherwise it will be treated as
- // a relative URL.
- link: 'http://$1',
- enabled: true,
- };
}
);
}
diff --git a/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text_test.ts b/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text_test.ts
index 38606c7..723267e 100644
--- a/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text_test.ts
+++ b/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text_test.ts
@@ -240,18 +240,7 @@
element.content = url;
await element.updateComplete;
const a = queryAndAssert<HTMLElement>(element, 'a');
-
- // URLs without scheme are upgraded to https:// by the
- // ALWAYS_LINK_SCHEMELESS rule. URLs with http:// or https://
- // are preserved by the ALWAYS_LINK_HTTP rule.
- const isSchemeless =
- !url.startsWith('http://') &&
- !url.startsWith('https://') &&
- !url.startsWith('mailto:') &&
- !url.startsWith('/');
- const expectedHref = isSchemeless ? `http://${url}` : url;
-
- assert.equal(a.getAttribute('href'), expectedHref);
+ assert.equal(a.getAttribute('href'), url);
assert.equal(a.innerText, url);
};
@@ -265,14 +254,6 @@
await checkLinking(
'https://google.com/traces/list?project=gerrit&tid=123'
);
-
- await checkLinking('www.google.com');
- await checkLinking('www.google.com/path');
- await checkLinking('google.com');
- await checkLinking('sub.google.co.uk');
- await checkLinking('google-foo.com');
- await checkLinking('google.io');
- await checkLinking('google.com?q=1#frag');
});
});
@@ -767,18 +748,7 @@
await element.updateComplete;
const a = queryAndAssert<HTMLElement>(element, 'a');
const p = queryAndAssert<HTMLElement>(element, 'p');
-
- // URLs without scheme are upgraded to https:// by the
- // ALWAYS_LINK_SCHEMELESS rule. URLs with http:// or https://
- // are preserved by the ALWAYS_LINK_HTTP rule.
- const isSchemeless =
- !url.startsWith('http://') &&
- !url.startsWith('https://') &&
- !url.startsWith('mailto:') &&
- !url.startsWith('/');
- const expectedHref = isSchemeless ? `http://${url}` : url;
-
- assert.equal(a.getAttribute('href'), expectedHref);
+ assert.equal(a.getAttribute('href'), url);
assert.equal(p.innerText, url);
};
@@ -789,14 +759,6 @@
await checkLinking(
'https://google.com/traces/list?project=gerrit&tid=123'
);
-
- await checkLinking('www.google.com');
- await checkLinking('www.google.com/path');
- await checkLinking('google.com');
- await checkLinking('sub.google.co.uk');
- await checkLinking('google-foo.com');
- await checkLinking('google.io');
- await checkLinking('google.com?q=1#frag');
});
suite('user suggest fix', () => {