@@ -199,28 +199,29 @@ protected function _linkUrls(string $text, array $htmlOptions): string {
199
199
}
200
200
201
201
/**
202
- * @param string $link
202
+ * @param string $name
203
203
* @param array $options Options:
204
204
* - stripProtocol: bool (defaults to true)
205
205
* - maxLength: int (defaults to 50)
206
206
* - ellipsis (defaults to UTF8 version)
207
+ *
207
208
* @return string html/$plain
208
209
*/
209
- public function prepareLinkName (string $ link , array $ options = []): string {
210
+ public function prepareLinkName (string $ name , array $ options = []): string {
210
211
// strip protocol if desired (default)
211
212
if (!isset ($ options ['stripProtocol ' ]) || $ options ['stripProtocol ' ] !== false ) {
212
- $ link = $ this -> stripProtocol ( $ link );
213
+ $ name = ( string ) preg_replace ( ' (^https?://) ' , '' , $ name );
213
214
}
214
215
if (!isset ($ options ['maxLength ' ])) {
215
216
$ options ['maxLength ' ] = 50 ; # should be long enough for most cases
216
217
}
217
218
// shorten display name if desired (default)
218
- if (!empty ($ options ['maxLength ' ]) && mb_strlen ($ link ) > $ options ['maxLength ' ]) {
219
- $ link = mb_substr ($ link , 0 , $ options ['maxLength ' ]);
220
- $ link .= $ options ['ellipsis ' ] ?? '… ' ;
219
+ if (!empty ($ options ['maxLength ' ]) && mb_strlen ($ name ) > $ options ['maxLength ' ]) {
220
+ $ name = mb_substr ($ name , 0 , $ options ['maxLength ' ]);
221
+ $ name .= $ options ['ellipsis ' ] ?? '… ' ;
221
222
}
222
223
223
- return $ link ;
224
+ return $ name ;
224
225
}
225
226
226
227
}
0 commit comments