From 9a40da63d3f79ce9fcaafcec4350981f989dd704 Mon Sep 17 00:00:00 2001 From: Christoph Hagen Date: Sun, 4 Sep 2022 17:45:44 +0200 Subject: [PATCH] Allow absolute urls for link preview thumbnails --- WebsiteGenerator/Files/ValidationLog.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/WebsiteGenerator/Files/ValidationLog.swift b/WebsiteGenerator/Files/ValidationLog.swift index f2abf3e..2f81790 100644 --- a/WebsiteGenerator/Files/ValidationLog.swift +++ b/WebsiteGenerator/Files/ValidationLog.swift @@ -106,8 +106,12 @@ final class ValidationLog { func linkPreviewThumbnail(customFile: String?, for language: String, in folder: URL, source: String) -> String? { if let customFile = customFile { - #warning("Allow absolute urls for link preview thumbnails") - let customFileUrl = folder.appendingPathComponent(customFile) + let customFileUrl: URL + if customFile.starts(with: "/") { + customFileUrl = URL(fileURLWithPath: customFile) + } else { + customFileUrl = folder.appendingPathComponent(customFile) + } guard customFileUrl.exists else { missing(customFile, requiredBy: "property 'linkPreviewImage' in metadata of \(source)") return nil