From b2d5d78596bbd7aa1cb11169860435321708c006 Mon Sep 17 00:00:00 2001 From: tai2 Date: Sun, 5 Nov 2023 09:56:29 +0900 Subject: [PATCH] Fix: error on relative image path --- deno.lock | 7 ------- src/template_renderer.ts | 2 +- src/template_renderer_test.ts | 17 +++++++++++++++++ 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/deno.lock b/deno.lock index ee2dae2..45101dc 100644 --- a/deno.lock +++ b/deno.lock @@ -141,13 +141,6 @@ "https://deno.land/std@0.204.0/path/windows/to_file_url.ts": "8e9ea9e1ff364aa06fa72999204229952d0a279dbb876b7b838b2b2fea55cce3", "https://deno.land/std@0.204.0/path/windows/to_namespaced_path.ts": "e0f4d4a5e77f28a5708c1a33ff24360f35637ba6d8f103d19661255ef7bfd50d", "https://deno.land/std@0.204.0/testing/mock.ts": "6576b4aa55ee20b1990d656a78fff83599e190948c00e9f25a7f3ac5e9d6492d", - "https://deno.land/std@0.204.0/url/_strip.ts": "86f852d266b86e5867f50ac5d453bedea7b7e7a1919669df93d66a0b59b00e5b", - "https://deno.land/std@0.204.0/url/basename.ts": "1257643f9934b65696d8af3ad993b3269d55231e6258ac13fba3d4fe193f30be", - "https://deno.land/std@0.204.0/url/dirname.ts": "65a0c5d4a62a6505404ea992fb73a2201c66e208aa7dfeb76d34f275432eddd0", - "https://deno.land/std@0.204.0/url/extname.ts": "d16f2a3bdccd1ef389a0a066a8275fa59089a04ae98cb69d753e228845d6256f", - "https://deno.land/std@0.204.0/url/join.ts": "fbc3488c641c38832f0c900fcf99cb970164d8e32b84f1427581bb83cf35efeb", - "https://deno.land/std@0.204.0/url/mod.ts": "d4e4db2f85a4a1613d824367b750f36bbd1c0ff791daae2eb74795d292c722bb", - "https://deno.land/std@0.204.0/url/normalize.ts": "5c5803452521a36faec1a91bdb665e1cbdf7ce22bc0482388ad79f229b74cd45", "https://deno.land/x/deno_dom@v0.1.42/build/deno-wasm/deno-wasm.js": "d6841a06342eb6a2798ef28de79ad69c0f2fa349fa04d3ca45e5fcfbf50a9340", "https://deno.land/x/deno_dom@v0.1.42/deno-dom-wasm.ts": "a33d160421bbb6e3104285ea5ebf33352b7ad50d82ea8765e3cf65f972b25119", "https://deno.land/x/deno_dom@v0.1.42/src/api.ts": "0ff5790f0a3eeecb4e00b7d8fbfa319b165962cf6d0182a65ba90f158d74f7d7", diff --git a/src/template_renderer.ts b/src/template_renderer.ts index 0814258..57fe6df 100644 --- a/src/template_renderer.ts +++ b/src/template_renderer.ts @@ -1,4 +1,4 @@ -import { extname } from './deps/std/url.ts' +import { extname } from './deps/std/path.ts' import { contentType } from './deps/std/media_types.ts' import { Element } from './deps/deno-dom.ts' import { cleanUrl, escape } from './deps/marked.ts' diff --git a/src/template_renderer_test.ts b/src/template_renderer_test.ts index 7a30a03..a72f65a 100644 --- a/src/template_renderer_test.ts +++ b/src/template_renderer_test.ts @@ -592,6 +592,23 @@ Deno.test( }, ) +Deno.test( + '`templateRenderer.image` can receive and render relative image path', + () => { + const imageTemplate = parseDomFragment( + ``, + ).children[0] + + assertEquals( + templateRenderer({ + ...testTemplate, + image: imageTemplate, + }).image('a.jpeg', 'title text', 'description text'), + `description text`, + ) + }, +) + Deno.test( '`templateRenderer.image` renders received parameters with video template when the file extention is a video one', () => {