Repository: refined-github/refined-github
Pull request #8300 (2025-02-25 15:30:06)

`small-user-avatars` - Don't quote avatar into comment field
Close: #8218



## Test URLs

#8218

## Screenshot

https://github.com/user-attachments/assets/1899da15-c701-4518-8f60-3b5c09f725ad




Patch:
diff --git a/build/__snapshots__/features-meta.json b/build/__snapshots__/features-meta.json
index 625d0abe..4fc063b2 100644
--- a/build/__snapshots__/features-meta.json
+++ b/build/__snapshots__/features-meta.json
@@ -832,6 +832,7 @@
 	{
 		"id": "small-user-avatars",
 		"description": "Shows a small avatar next to the username in issue/PR lists and mentions.",
+		"css": true,
 		"screenshot": "https://github-production-user-asset-6210df.s3.amazonaws.com/1402241/271184107-24ec471e-54d1-434a-a5f2-615902d2cad9.png"
 	},
 	{
diff --git a/source/features/small-user-avatars.css b/source/features/small-user-avatars.css
new file mode 100644
index 00000000..4842cb56
--- /dev/null
+++ b/source/features/small-user-avatars.css
@@ -0,0 +1,12 @@
+.rgh-mention-avatar::before {
+	content: '';
+	display: inline-block;
+	width: 16px;
+	height: 16px;
+	margin-right: 0.2em;
+	border-radius: 50%;
+	background-image: var(--avatar-url);
+	background-size: cover;
+	background-position: center;
+	vertical-align: middle;
+}
diff --git a/source/features/small-user-avatars.tsx b/source/features/small-user-avatars.tsx
index 90493535..c98a5c7d 100644
--- a/source/features/small-user-avatars.tsx
+++ b/source/features/small-user-avatars.tsx
@@ -5,6 +5,7 @@ import features from '../feature-manager.js';
 import {assertNodeContent} from '../helpers/dom-utils.js';
 import observe from '../helpers/selector-observer.js';
 import getUserAvatarURL from '../github-helpers/get-user-avatar.js';
+import './small-user-avatars.css';
 
 function addAvatar(link: HTMLElement): void {
 	const username = link.textContent;
@@ -25,18 +26,10 @@ function addAvatar(link: HTMLElement): void {
 function addMentionAvatar(link: HTMLElement): void {
 	assertNodeContent(link.firstChild, /^@/);
 	const username = link.textContent.slice(1);
-	const size = 16;
+	const avatarUrl = getUserAvatarURL(username, 16);
 
-	link.prepend(
-		<img
-			className="avatar avatar-user mb-1 mr-1 rgh-small-user-avatars"
-			style={{marginLeft: 1}}
-			src={getUserAvatarURL(username, size)!}
-			width={size}
-			height={size}
-			loading="lazy"
-		/>,
-	);
+	link.classList.add('rgh-small-user-avatars', 'rgh-mention-avatar');
+	link.style.setProperty('--avatar-url', `url(${avatarUrl})`);
 }
 
 function initOnce(): void {
diff --git a/source/helpers/conventional-commits.ts b/source/helpers/conventional-commits.ts
index 4cb683af..ac78102c 100644
--- a/source/helpers/conventional-commits.ts
+++ b/source/helpers/conventional-commits.ts
@@ -1,5 +1,5 @@
 // Using https://www.conventionalcommits.org/ as a reference.
-export const conventionalCommitRegex = /^(?<type>\w+)(?:\((?<scope>.+)\))?(?<major>!)?: */;
+export const conventionalCommitRegex = /^(?<type>\w+)(?:\((?<scope>.+?)\))?(?<major>!)?: */;
 
 // Do not send PRs for types not listed here: https://github.com/conventional-changelog/commitlint/tree/master/%40commitlint/config-conventional#rules
 // No more types will be added nor do we accept options.


Test patch:
diff --git a/source/helpers/conventional-commits.test.ts b/source/helpers/conventional-commits.test.ts
index 4267986c..1d7a3ef7 100644
--- a/source/helpers/conventional-commits.test.ts
+++ b/source/helpers/conventional-commits.test.ts
@@ -43,6 +43,14 @@ test('parseConventionalCommit', () => {
 		  "type": "Feature!",
 		}
 	`);
+	expect(parseConventionalCommit('revert(scope): Revert "feat(scope): Commit message"')).toMatchInlineSnapshot(`
+		{
+		  "raw": "revert(scope): ",
+		  "rawType": "revert",
+		  "scope": "scope: ",
+		  "type": "Revert",
+		}
+	`);
 	expect(parseConventionalCommit('feat(sco pe): Commit message')).toMatchInlineSnapshot(`
 		{
 		  "raw": "feat(sco pe): ",