sveltekit-data-plugin 1.5.1 → 1.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/plugin.js CHANGED
@@ -3,8 +3,11 @@
3
3
  })(this, function(fm, path, fs) {
4
4
  "use strict";
5
5
  const REGEX = {
6
- IMAGE: /^\S*(jpg|png|webp|avif|jpeg)$/,
7
- YOUTUBE: /^(https?\:\/\/)?((www\.)?youtube\.com|youtu\.be)\/.+$/
6
+ IMAGE: new RegExp(/^\S*(jpg|png|webp|avif|jpeg)$/, "i"),
7
+ YOUTUBE: new RegExp(
8
+ /^(https?\:\/\/)?((www\.)?youtube\.com|youtu\.be)\/.+$/,
9
+ "i"
10
+ )
8
11
  };
9
12
  function oembed(type, url) {
10
13
  switch (type) {
@@ -30,7 +33,7 @@
30
33
  }
31
34
  }
32
35
  function stampURL(src, base) {
33
- return `${path.resolve(base, src)}?enhanced`;
36
+ return `${path.resolve(base, src.toLowerCase())}?enhanced`;
34
37
  }
35
38
  function parseObject(str) {
36
39
  const updated = str.replaceAll(/{(\n\s*)?/gm, '{"').replaceAll(":", '":').replaceAll(/,(\n\s*)?([^ ])/g, ',"$2');
@@ -48,7 +51,10 @@
48
51
  opts.plugin_context,
49
52
  stampURL(obj, obj.startsWith("./") && relative ? relative : base)
50
53
  );
51
- return parseObject(img.slice("export default".length, -1));
54
+ return {
55
+ ...parseObject(img.slice("export default".length, -1)),
56
+ _filename: obj
57
+ };
52
58
  } catch (e) {
53
59
  return {
54
60
  src: null
package/dist/plugin.mjs CHANGED
@@ -2,8 +2,11 @@ import fm from "front-matter";
2
2
  import path from "path";
3
3
  import fs from "fs/promises";
4
4
  const REGEX = {
5
- IMAGE: /^\S*(jpg|png|webp|avif|jpeg)$/,
6
- YOUTUBE: /^(https?\:\/\/)?((www\.)?youtube\.com|youtu\.be)\/.+$/
5
+ IMAGE: new RegExp(/^\S*(jpg|png|webp|avif|jpeg)$/, "i"),
6
+ YOUTUBE: new RegExp(
7
+ /^(https?\:\/\/)?((www\.)?youtube\.com|youtu\.be)\/.+$/,
8
+ "i"
9
+ )
7
10
  };
8
11
  function oembed(type, url) {
9
12
  switch (type) {
@@ -29,7 +32,7 @@ function oembed(type, url) {
29
32
  }
30
33
  }
31
34
  function stampURL(src, base) {
32
- return `${path.resolve(base, src)}?enhanced`;
35
+ return `${path.resolve(base, src.toLowerCase())}?enhanced`;
33
36
  }
34
37
  function parseObject(str) {
35
38
  const updated = str.replaceAll(/{(\n\s*)?/gm, '{"').replaceAll(":", '":').replaceAll(/,(\n\s*)?([^ ])/g, ',"$2');
@@ -47,7 +50,10 @@ async function convert(opts, obj, { base, relative, depth = 1 } = {}) {
47
50
  opts.plugin_context,
48
51
  stampURL(obj, obj.startsWith("./") && relative ? relative : base)
49
52
  );
50
- return parseObject(img.slice("export default".length, -1));
53
+ return {
54
+ ...parseObject(img.slice("export default".length, -1)),
55
+ _filename: obj
56
+ };
51
57
  } catch (e) {
52
58
  return {
53
59
  src: null
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sveltekit-data-plugin",
3
- "version": "1.5.1",
3
+ "version": "1.5.3",
4
4
  "author": {
5
5
  "name": "Jonny Thaw",
6
6
  "url": "https://jthaw.me"