torchlight-laravel icon indicating copy to clipboard operation
torchlight-laravel copied to clipboard

(Auto)linking for non-http(s) and non-www URLs

Open shaedrich opened this issue 10 months ago • 0 comments

Your autolinking feature is awesome. But it would be even better if there could be either

  • an annotation
  • a config option
```shell
composer install torchlight-api/torchlight [tl! autolink]
```

to allow for non-http(s) and non-www URLs to be linked which either

  • just have different scheme/protocol (could be turned on by either an object whose value is true or an array list)
  • requires mapping (which could be implemented with either a function or regexp replacements)
<?php

return [
    'links' => [
        // either
        'protocols' => [ 'https', 'ftp', 'vscode' ],
        // or
        'protocols' => [
            'https' => true,
            'http' => false,
            // or
            'ftp' => [ '/^ftp:\/\/(?<username>(.*)(?=:)):(?<password>(.*)(?=@))@(.*)$/', 'ftp://$url?username=$username&password=$password' ],
            // or
            'vscode' => fn (string $url) => explode('?', $url)[0],
        ],
    ],
];

shaedrich avatar Feb 17 '25 19:02 shaedrich