mindspace: close authority boundaries
This commit is contained in:
@@ -19,13 +19,19 @@ export function buildPublishedHtmlViewContext({
|
||||
origin = '',
|
||||
requestPath = '',
|
||||
filePath = '',
|
||||
servedName = '',
|
||||
fallbackImageName = '',
|
||||
thumbnailPngPathForSvg = (value) => value,
|
||||
fileExists = fs.existsSync,
|
||||
} = {}) {
|
||||
const cleanPath = String(requestPath ?? '').split('?')[0].split('#')[0];
|
||||
const servedName = path.basename(String(filePath ?? ''));
|
||||
const resolvedServedName =
|
||||
String(servedName ?? '').trim() ||
|
||||
path.basename(String(filePath ?? ''));
|
||||
const urlLast = decodeURIComponent(cleanPath.split('/').filter(Boolean).pop() ?? '');
|
||||
const isImplicitIndex = urlLast.toLowerCase() !== servedName.toLowerCase();
|
||||
const isImplicitIndex =
|
||||
urlLast.toLowerCase() !==
|
||||
resolvedServedName.toLowerCase();
|
||||
const pageUrl = !origin
|
||||
? ''
|
||||
: `${origin}${isImplicitIndex && !cleanPath.endsWith('/') ? `${cleanPath}/` : cleanPath}`;
|
||||
@@ -36,8 +42,12 @@ export function buildPublishedHtmlViewContext({
|
||||
: `${origin}${cleanPath.slice(0, cleanPath.lastIndexOf('/') + 1)}`;
|
||||
|
||||
let fallbackImageUrl = '';
|
||||
const logicalFallbackName =
|
||||
String(fallbackImageName ?? '').trim();
|
||||
const svgSibling = String(filePath ?? '').replace(/\.[^./]+$/, '.thumbnail.svg');
|
||||
if (pageDirUrl && fileExists(svgSibling)) {
|
||||
if (pageDirUrl && logicalFallbackName) {
|
||||
fallbackImageUrl = `${pageDirUrl}${encodeURIComponent(logicalFallbackName)}`;
|
||||
} else if (pageDirUrl && fileExists(svgSibling)) {
|
||||
const pngName = path.basename(thumbnailPngPathForSvg(svgSibling));
|
||||
fallbackImageUrl = `${pageDirUrl}${pngName}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user