lightnet 3.1.0 → 3.1.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # lightnet
2
2
 
3
+ ## 3.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#243](https://github.com/LightNetDev/LightNet/pull/243) [`735e984`](https://github.com/LightNetDev/LightNet/commit/735e984ee00e67bc0d326e4e67efd45cf10b73e0) Thanks [@smn-cds](https://github.com/smn-cds)! - Fix open button label for websites
8
+
9
+ Before website links e.g. https://wikipedia.org showed a "Download" button on the details page.
10
+ With this fix they show a "Open" button.
11
+
3
12
  ## 3.1.0
4
13
 
5
14
  ### Minor Changes
package/README.md CHANGED
@@ -6,7 +6,7 @@ LightNet is built as an integration for the [Astro](https://astro.build) framewo
6
6
 
7
7
  ## Documentation
8
8
 
9
- [Read the LightNet docs](https://lightnet-docs.pages.dev) to learn how to use LightNet.
9
+ [Read the LightNet docs](https://docs.lightnet.community) to learn how to use LightNet.
10
10
 
11
11
  ## Example site
12
12
 
@@ -25,6 +25,17 @@ test("Should create complete content metadata", () => {
25
25
  type: "link",
26
26
  },
27
27
  },
28
+ {
29
+ url: "https://wikipedia.org",
30
+ expected: {
31
+ canBeOpened: true,
32
+ target: "_blank",
33
+ label: "wikipedia.org",
34
+ isExternal: true,
35
+ extension: "",
36
+ type: "link",
37
+ },
38
+ },
28
39
  {
29
40
  url: "https://some.host/some.pDf",
30
41
  expected: {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "lightnet",
3
3
  "type": "module",
4
4
  "license": "MIT",
5
- "version": "3.1.0",
5
+ "version": "3.1.1",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/LightNetDev/lightnet",
@@ -49,17 +49,18 @@ export function createContentMetadata({
49
49
  url: string
50
50
  label?: string
51
51
  }) {
52
- const lastUrlSegment = url.split("/").slice(-1)[0]
53
- const hasExtension = lastUrlSegment.includes(".")
52
+ const isExternal = isExternalUrl(url)
53
+ const path = isExternal ? new URL(url).pathname : url
54
+
55
+ const lastPathSegment = path.split("/").slice(-1)[0]
56
+ const hasExtension = lastPathSegment.includes(".")
54
57
  const extension = hasExtension
55
- ? lastUrlSegment.split(".").slice(-1)[0].toLowerCase()
58
+ ? lastPathSegment.split(".").slice(-1)[0].toLowerCase()
56
59
  : ""
57
60
 
58
- const isExternal = isExternalUrl(url)
59
-
60
- const linkName = isExternal ? new URL(url).hostname : lastUrlSegment
61
+ const linkName = isExternal ? new URL(url).hostname : lastPathSegment
61
62
  const fileName = hasExtension
62
- ? lastUrlSegment.slice(0, -(extension.length + 1))
63
+ ? lastPathSegment.slice(0, -(extension.length + 1))
63
64
  : undefined
64
65
  const label = customLabel ?? fileName ?? linkName
65
66
  const type = KNOWN_EXTENSIONS[extension]?.type ?? "link"