From 0bb291082a18facf51a3aa12a0a373b06683fe5d Mon Sep 17 00:00:00 2001 From: filesite Date: Fri, 1 Apr 2022 03:00:09 +0800 Subject: [PATCH] function fixMDUrls improved to support absolute urls --- lib/DirScanner.php | 5 +++-- test/init_test_files.sh | 10 ++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/DirScanner.php b/lib/DirScanner.php index 2838f87..f1930f7 100644 --- a/lib/DirScanner.php +++ b/lib/DirScanner.php @@ -600,9 +600,10 @@ Class DirScanner { if (!empty($matches)) { foreach ($matches as $url) { - if (preg_match('/^http(s)?:\/\//i', $url)) {continue;} + if (preg_match('/^http(s)?:\/\//i', $url) || preg_match('/^\//i', $url)) {continue;} + + $src_realpath = !preg_match('/^\.\//', $url) ? "{$pathinfo['dirname']}/{$url}" : "{$pathinfo['dirname']}/" . preg_replace('/^\.\//', '', $url); - $src_realpath = "{$pathinfo['dirname']}/{$url}"; if (file_exists($src_realpath)) { $id = $this->getId($src_realpath); $fp = fopen($src_realpath, 'r'); diff --git a/test/init_test_files.sh b/test/init_test_files.sh index 01da4ed..9eaacd2 100755 --- a/test/init_test_files.sh +++ b/test/init_test_files.sh @@ -36,15 +36,21 @@ tee "Readme.md" <谷歌图片搜索 -Bing图片搜索 +Bing图片搜索 +Bing图片搜索 + +网站ICON: +Google +Bing ## 小说 常用的小说网站。 金庸小说 -古龙小说 +古龙小说 EOF