From e6a1082cdf54e483ec07bd9dc7bb184bc0a1158c Mon Sep 17 00:00:00 2001 From: Hans Fast Date: Sat, 22 Nov 2025 08:07:42 +0100 Subject: [PATCH] test case for custom filetype handler --- README.md | 34 ++++++++++++++++++++++++++++++++++ config.ori | 5 +++++ foo.handler.js | 8 ++++++++ foobar.foo | 1 + 4 files changed, 48 insertions(+) create mode 100644 README.md create mode 100644 config.ori create mode 100644 foo.handler.js create mode 100644 foobar.foo diff --git a/README.md b/README.md new file mode 100644 index 0000000..14553bc --- /dev/null +++ b/README.md @@ -0,0 +1,34 @@ +# filetype handler not working as expected + +Following the [docs](https://weborigami.org/language/filetypes#custom-file-types), I have created a file `foobar.foo` and a handler `foo.handler.js`. + +```text +#foobar.fo +This is the original text +``` + +```javascript +//foo.handler.js +//I believe this is not being used, because in doctree.js, isUnpackable is false, and toString is not exported by @weborigami/origami anymore ... ? +import { toString } from "@weborigami/origami"; + +export default { + mediaType: "application/json", + unpack: (packed) => { return {what: "a text file"} } +} +``` + +``` +//config.ori +{ + hello = "world" + foo.handler = ./dj.handler.js +} +``` + +## Expected/Actual results: + +When running `ori foobar.foo/`, I would expect to receive an object `{what: "a text file"}` but I receive the original text in `foobar.foo`. + + + diff --git a/config.ori b/config.ori new file mode 100644 index 0000000..44bcf4b --- /dev/null +++ b/config.ori @@ -0,0 +1,5 @@ +{ + hello = "world" + foo.handler = ./dj.handler.js +} + diff --git a/foo.handler.js b/foo.handler.js new file mode 100644 index 0000000..e557560 --- /dev/null +++ b/foo.handler.js @@ -0,0 +1,8 @@ +//I believe this is not being used, because in doctree.js, isUnpackable is false, and toString is not exported by @weborigami/origami anymore ... ? +import { toString } from "@weborigami/origami"; + +export default { + mediaType: "application/json", + unpack: (packed) => { return {what: "a text file"} } +} + diff --git a/foobar.foo b/foobar.foo new file mode 100644 index 0000000..44a9436 --- /dev/null +++ b/foobar.foo @@ -0,0 +1 @@ +This is the original text