@sitecore-feaas/clientside 0.1.31 → 0.1.32

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sitecore-feaas/clientside",
3
- "version": "0.1.31",
3
+ "version": "0.1.32",
4
4
  "scripts": {
5
5
  "start": "webpack serve --open",
6
6
  "build": "rm -rf dist;npm run types; npm run build:esbuild; npm run build:sourcemaps",
package/src/cdn.ts CHANGED
@@ -69,7 +69,7 @@ export function getStylesheetSource(props: FEAASCDNStylesheetParams) {
69
69
  }
70
70
 
71
71
  export function parseStylesheetSource(source: string): FEAASCDNStylesheetParams {
72
- const match = source.match(/^(?:(.*?)\/styles)?\/([^\/]+)\/([^\/]+)(?:.css?)?$/)
72
+ const match = source.match(/^(?:(.*?)\/styles)?\/([^\/]+)(?:\/([^\/]+?)(?:.css))?$/)
73
73
  if (match) {
74
74
  var [, cdn, library, revision] = match
75
75
  return { cdn, library, revision: revision as any }
@@ -92,7 +92,7 @@ export function getStylesheetURL(props: FEAASCDNStylesheetProps) {
92
92
  }
93
93
  if ('src' in props) {
94
94
  props = {
95
- ...parseComponentSource(props.src)
95
+ ...parseStylesheetSource(props.src)
96
96
  }
97
97
  }
98
98
  return `${props.cdn || props.hostname || DEFAULT_CDN_URL}/styles/${props.library}/${
package/test/cdn.ts CHANGED
@@ -1,5 +1,12 @@
1
1
  import { describe, it, assert, beforeAll, expect } from 'vitest'
2
- import { parseComponentSource, getComponentSource, DEFAULT_CDN_URL } from '../src/cdn.js'
2
+ import {
3
+ parseComponentSource,
4
+ getComponentSource,
5
+ DEFAULT_CDN_URL,
6
+ getStylesheetSource,
7
+ parseStylesheetSource,
8
+ getStylesheetURL
9
+ } from '../src/cdn.js'
3
10
  import { CH1Node, serializeCH1RichText } from '../src/dom/data.js'
4
11
  describe('CDN', function () {
5
12
  it('should parse and serialize component src', function () {
@@ -36,4 +43,17 @@ describe('CDN', function () {
36
43
  )
37
44
  ).toEqual('library/component')
38
45
  })
46
+ it('should parse and serialize stylesheet src', function () {
47
+ expect(
48
+ getStylesheetSource(
49
+ parseStylesheetSource('https://feaaslocal.blob.core.windows.net/styles/clean-demo/published.css')
50
+ )
51
+ ).toEqual('https://feaaslocal.blob.core.windows.net/styles/clean-demo')
52
+ expect(getStylesheetURL('https://feaaslocal.blob.core.windows.net/styles/clean-demo')).toEqual(
53
+ 'https://feaaslocal.blob.core.windows.net/styles/clean-demo/published.css'
54
+ )
55
+ expect(getStylesheetURL('https://feaaslocal.blob.core.windows.net/styles/clean-demo/published.css')).toEqual(
56
+ 'https://feaaslocal.blob.core.windows.net/styles/clean-demo/published.css'
57
+ )
58
+ })
39
59
  })