Repository: platers/obsidian-linter (ts)

Issue:
Bug: no bare URL will contain some illegal characters
- [x] I have verified that I am on the latest version of the Linter

## Describe the Bug

I am a Chinese language speaker and I want to directly follow Chinese characters after URLs, but I will include these Chinese characters

## How to Reproduce

original sentence
```
我是一个网址https://github.com/platers/obsidian-linter一些中文字符。被包含进去了
```
After pressing ctrl+s to format
```
我是一个网址<https://github.com/platers/obsidian-linter一些中文字符。被包含进去了>
```
If I continue to add
```
我是一个网址<https://github.com/platers/obsidian-linter一些中文字符。被包含进去了>如果我继续写
```
Press ctrl+s again
```
我是一个网址<<https://github.com/platers/obsidian-linter一些中文字符。被包含进去了>如果我继续写>
```

## Device

- [x] Desktop
- [ ] Mobile

## Additional Context

V1.19.1 does not meet this issue, V1.20.0 meet this issue

Pull request:
`No Bare URLs` Should not Include `>` or Chinese Characters
Fixes #900 

Changes Made:
- Added UTs for the 2 scenarios referenced
- Simplified regex to no longer accept just about anything to just include English letter, numbers, and some special URL characters

Patch:
diff --git a/src/utils/regex.ts b/src/utils/regex.ts
index 8b0f902..35c872f 100644
--- a/src/utils/regex.ts
+++ b/src/utils/regex.ts
@@ -24,7 +24,7 @@ export const tableRow = /[^\n]*?\|[^\n]*?(\n|$)/m;
 // based on https://gist.github.com/skeller88/5eb73dc0090d4ff1249a
 export const simpleURIRegex = /(([a-z\-0-9]+:)\/{2})([^\s/?#]*[^\s")'.?!/]|[/])?(([/?#][^\s")']*[^\s")'.?!])|[/])?/gi;
 // generated from https://github.com/spamscanner/url-regex-safe using strict: true, returnString: true, and re2: false as options
-export const urlRegex = /(?:(?:(?:[a-z]+:)?\/\/)|www\.)(?:localhost|(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?:(?:[a-fA-F\d]{1,4}:){7}(?:[a-fA-F\d]{1,4}|:)|(?:[a-fA-F\d]{1,4}:){6}(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-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[a-fA-F\d]{1,4}){1,5}|:)|(?:[a-fA-F\d]{1,4}:){1}(?:(?::[a-fA-F\d]{1,4}){0,4}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-fA-F\d]{1,4}){1,6}|:)|(?::(?:(?::[a-fA-F\d]{1,4}){0,5}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-fA-F\d]{1,4}){1,7}|:)))(?:%[0-9a-zA-Z]{1,})?|(?:(?:[a-z0-9][-_]*)*[a-z0-9]+)(?:\.(?:[a-z0-9]-*)*[a-z0-9]+)*(?:\.(?:[a-z]{2,})))(?::\d{2,5})?(?:(?:[/?#][a-z0-9-_/$.+!*‘(,]*[a-z0-9-_/$+!*‘(,])|[/])?/gi;
 export const anchorTagRegex = /<a[\s]+([^>]+)>((?:.(?!<\/a>))*.)<\/a>/g;
 export const wordRegex = /[\p{L}\p{N}\p{Pc}\p{M}\-'’`]+/gu;
 // regex from https://stackoverflow.com/a/26128757/8353749


Test patch:
diff --git a/__tests__/no-bare-urls.test.ts b/__tests__/no-bare-urls.test.ts
index 7ec9436..af42292 100644
--- a/__tests__/no-bare-urls.test.ts
+++ b/__tests__/no-bare-urls.test.ts
@@ -124,6 +124,24 @@ ruleTest({
         [This Is Fats Domino!]: <https://en.wikipedia.org/wiki/This_Is_Fats_Domino!>
       `,
     },
+    {// accounts for https://github.com/platers/obsidian-linter/issues/900
+      testName: 'Make sure that a link ending in a blob of text without spaces does not include `>`',
+      before: dedent`
+        我是一个网址<https://github.com/platers/obsidian-linter>一些中文字符。被包含进去了如果我继续写
+      `,
+      after: dedent`
+        我是一个网址<https://github.com/platers/obsidian-linter>一些中文字符。被包含进去了如果我继续写
+      `,
+    },
+    {// accounts for https://github.com/platers/obsidian-linter/issues/900
+      testName: 'Chinese is not allowed in links',
+      before: dedent`
+        我是一个网址https://github.com/platers/obsidian-linter一些中文字符。被包含进去了
+      `,
+      after: dedent`
+        我是一个网址<https://github.com/platers/obsidian-linter>一些中文字符。被包含进去了
+      `,
+    },
   ],
 });