Repository: thephpleague/commonmark (php)

Issue:
StrikethroughExtension does not work with links
### Version(s) affected

2.3.0

### Description

StrikethroughExtension does not work with links. 

Input: `~~Prefix i link: https://aws.amazon.com/emr/features/hadoop/~~`
Expected output: 

```
<p>
  <del>
    Prefiks i link: <a href="https://aws.amazon.com/emr/features/hadoop/">https://aws.amazon.com/emr/features/hadoop/
    </a>
  </del>
</p
```

CommonMark output: 
```
<p>
  ~~Prefiks i link: https://aws.amazon.com/emr/features/hadoop/~~
</p>
```

### How to reproduce

```php
$environment = new Environment([]);
$environment->addExtension(new CommonMarkCoreExtension());
$environment->addExtension(new StrikethroughExtension());
$environment->addExtension(new AutolinkExtension());

$converter = new MarkdownConverter($environment);
$document = $converter->convert($text);

return (string) $document;
```

Pull request description:
Fix AutolinkExtension not ignoring trailing strikethrough syntax
Fixes #867 

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2ac93f27..23df8157 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,10 @@ Updates should follow the [Keep a CHANGELOG](https://keepachangelog.com/) princi
 
 ## [Unreleased][unreleased]
 
+### Fixed
+
+- Fixed AutolinkExtension not ignoring trailing strikethrough syntax (#867)
+
 ## [2.2.3] - 2022-02-26
 
 ### Fixed
diff --git a/src/Extension/Autolink/UrlAutolinkParser.php b/src/Extension/Autolink/UrlAutolinkParser.php
index 75af5aa9..e9071703 100644
--- a/src/Extension/Autolink/UrlAutolinkParser.php
+++ b/src/Extension/Autolink/UrlAutolinkParser.php
@@ -90,7 +90,7 @@ final class UrlAutolinkParser implements InlineParserInterface
         $url = $matches[0];
 
         // Does the URL end with punctuation that should be stripped?
-        if (\preg_match('/(.+)([?!.,:*_~]+)$/', $url, $matches)) {
+        if (\preg_match('/(.+?)([?!.,:*_~]+)$/', $url, $matches)) {
             // Add the punctuation later
             $url = $matches[1];
         }


Test patch:
diff --git a/tests/functional/Extension/Autolink/UrlAutolinkParserTest.php b/tests/functional/Extension/Autolink/UrlAutolinkParserTest.php
index d667c2c4..0f07f18c 100644
--- a/tests/functional/Extension/Autolink/UrlAutolinkParserTest.php
+++ b/tests/functional/Extension/Autolink/UrlAutolinkParserTest.php
@@ -16,6 +16,7 @@ namespace League\CommonMark\Tests\Functional\Extension\Autolink;
 use League\CommonMark\Environment\Environment;
 use League\CommonMark\Extension\Autolink\AutolinkExtension;
 use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension;
+use League\CommonMark\Extension\Strikethrough\StrikethroughExtension;
 use League\CommonMark\MarkdownConverter;
 use PHPUnit\Framework\TestCase;
 
@@ -88,4 +89,22 @@ final class UrlAutolinkParserTest extends TestCase
         // Issue 492: underscores in URLs (see https://github.com/thephpleague/commonmark/issues/492)
         yield ['http://wiki/Puncutation_in_links:_why_its_bad_(and_should_be_avoided)', '<p><a href="http://wiki/Puncutation_in_links:_why_its_bad_(and_should_be_avoided)">http://wiki/Puncutation_in_links:_why_its_bad_(and_should_be_avoided)</a></p>'];
     }
+
+    public function testUrlAutolinksWithStrikethrough(): void
+    {
+        $markdown = '~~Prefix i link: https://aws.amazon.com/emr/features/hadoop/~~';
+
+        $environment = new Environment();
+        $environment->addExtension(new CommonMarkCoreExtension());
+        $environment->addExtension(new AutolinkExtension());
+        $environment->addExtension(new StrikethroughExtension());
+
+        $converter = new MarkdownConverter($environment);
+        $html      = $converter->convert($markdown)->getContent();
+
+        $this->assertSame(
+            '<p><del>Prefix i link: <a href="https://aws.amazon.com/emr/features/hadoop/">https://aws.amazon.com/emr/features/hadoop/</a></del></p>' . "\n",
+            $html
+        );
+    }
 }