« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/composite
diff options
context:
space:
mode:
Diffstat (limited to 'src/data/composite')
-rw-r--r--src/data/composite/wiki-properties/canonicalBase.js16
-rw-r--r--src/data/composite/wiki-properties/index.js1
2 files changed, 17 insertions, 0 deletions
diff --git a/src/data/composite/wiki-properties/canonicalBase.js b/src/data/composite/wiki-properties/canonicalBase.js
new file mode 100644
index 00000000..81740d6c
--- /dev/null
+++ b/src/data/composite/wiki-properties/canonicalBase.js
@@ -0,0 +1,16 @@
+import {isURL} from '#validators';
+
+export default function() {
+  return {
+    flags: {update: true, expose: true},
+    update: {validate: isURL},
+    expose: {
+      transform: (value) =>
+        (value === null
+          ? null
+       : value.endsWith('/')
+          ? value
+          : value + '/'),
+    },
+  };
+}
diff --git a/src/data/composite/wiki-properties/index.js b/src/data/composite/wiki-properties/index.js
index e8f109d3..57a2b8f2 100644
--- a/src/data/composite/wiki-properties/index.js
+++ b/src/data/composite/wiki-properties/index.js
@@ -4,6 +4,7 @@
 // #composite/data, and #composite/wiki-data.
 
 export {default as annotatedReferenceList} from './annotatedReferenceList.js';
+export {default as canonicalBase} from './canonicalBase.js';
 export {default as color} from './color.js';
 export {default as commentatorArtists} from './commentatorArtists.js';
 export {default as constitutibleArtwork} from './constitutibleArtwork.js';