@verdaccio/middleware 7.0.0-next-7.19 → 7.0.0-next-7.20

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,16 @@
1
1
  # @verdaccio/middleware
2
2
 
3
+ ## 7.0.0-next-7.20
4
+
5
+ ### Patch Changes
6
+
7
+ - ccc7bd1: fix(middleware): link to favicon in template
8
+ - Updated dependencies [ccc7bd1]
9
+ - @verdaccio/url@12.0.0-next-7.20
10
+ - @verdaccio/core@7.0.0-next-7.20
11
+ - @verdaccio/config@7.0.0-next-7.20
12
+ - @verdaccio/utils@7.0.0-next-7.20
13
+
3
14
  ## 7.0.0-next-7.19
4
15
 
5
16
  ### Patch Changes
@@ -10,9 +10,15 @@ const debug = (0, _debug.default)('verdaccio:middleware:web:render:manifest');
10
10
  function getManifestValue(manifestItems, manifest, basePath = '') {
11
11
  return manifestItems === null || manifestItems === void 0 ? void 0 : manifestItems.map(item => {
12
12
  debug('resolve item %o', item);
13
- const resolvedItem = `${basePath}${manifest[item]}`;
13
+ const resolvedItem = `${stripTrailingSlash(basePath)}/${stripLeadingSlash(manifest[item])}`;
14
14
  debug('resolved item %o', resolvedItem);
15
15
  return resolvedItem;
16
16
  });
17
17
  }
18
+ function stripTrailingSlash(path) {
19
+ return path.replace(/\/$/, '');
20
+ }
21
+ function stripLeadingSlash(path) {
22
+ return path.replace(/^\//, '');
23
+ }
18
24
  //# sourceMappingURL=manifest.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"manifest.js","names":["_debug","_interopRequireDefault","require","e","__esModule","default","debug","buildDebug","getManifestValue","manifestItems","manifest","basePath","map","item","resolvedItem"],"sources":["../../../../src/middlewares/web/utils/manifest.ts"],"sourcesContent":["import buildDebug from 'debug';\n\nexport type Manifest = {\n // goes on first place at the header\n ico: string;\n css: string[];\n js: string[];\n};\n\nconst debug = buildDebug('verdaccio:middleware:web:render:manifest');\n\nexport function getManifestValue(\n manifestItems: string[],\n manifest,\n basePath: string = ''\n): string[] {\n return manifestItems?.map((item) => {\n debug('resolve item %o', item);\n const resolvedItem = `${basePath}${manifest[item]}`;\n debug('resolved item %o', resolvedItem);\n return resolvedItem;\n });\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA+B,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAS/B,MAAMG,KAAK,GAAG,IAAAC,cAAU,EAAC,0CAA0C,CAAC;AAE7D,SAASC,gBAAgBA,CAC9BC,aAAuB,EACvBC,QAAQ,EACRC,QAAgB,GAAG,EAAE,EACX;EACV,OAAOF,aAAa,aAAbA,aAAa,uBAAbA,aAAa,CAAEG,GAAG,CAAEC,IAAI,IAAK;IAClCP,KAAK,CAAC,iBAAiB,EAAEO,IAAI,CAAC;IAC9B,MAAMC,YAAY,GAAG,GAAGH,QAAQ,GAAGD,QAAQ,CAACG,IAAI,CAAC,EAAE;IACnDP,KAAK,CAAC,kBAAkB,EAAEQ,YAAY,CAAC;IACvC,OAAOA,YAAY;EACrB,CAAC,CAAC;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"manifest.js","names":["_debug","_interopRequireDefault","require","e","__esModule","default","debug","buildDebug","getManifestValue","manifestItems","manifest","basePath","map","item","resolvedItem","stripTrailingSlash","stripLeadingSlash","path","replace"],"sources":["../../../../src/middlewares/web/utils/manifest.ts"],"sourcesContent":["import buildDebug from 'debug';\n\nexport type Manifest = {\n // goes on first place at the header\n ico: string;\n css: string[];\n js: string[];\n};\n\nconst debug = buildDebug('verdaccio:middleware:web:render:manifest');\n\nexport function getManifestValue(\n manifestItems: string[],\n manifest,\n basePath: string = ''\n): string[] {\n return manifestItems?.map((item) => {\n debug('resolve item %o', item);\n const resolvedItem = `${stripTrailingSlash(basePath)}/${stripLeadingSlash(manifest[item])}`;\n debug('resolved item %o', resolvedItem);\n return resolvedItem;\n });\n}\n\nfunction stripTrailingSlash(path: string): string {\n return path.replace(/\\/$/, '');\n}\n\nfunction stripLeadingSlash(path: string): string {\n return path.replace(/^\\//, '');\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA+B,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAS/B,MAAMG,KAAK,GAAG,IAAAC,cAAU,EAAC,0CAA0C,CAAC;AAE7D,SAASC,gBAAgBA,CAC9BC,aAAuB,EACvBC,QAAQ,EACRC,QAAgB,GAAG,EAAE,EACX;EACV,OAAOF,aAAa,aAAbA,aAAa,uBAAbA,aAAa,CAAEG,GAAG,CAAEC,IAAI,IAAK;IAClCP,KAAK,CAAC,iBAAiB,EAAEO,IAAI,CAAC;IAC9B,MAAMC,YAAY,GAAG,GAAGC,kBAAkB,CAACJ,QAAQ,CAAC,IAAIK,iBAAiB,CAACN,QAAQ,CAACG,IAAI,CAAC,CAAC,EAAE;IAC3FP,KAAK,CAAC,kBAAkB,EAAEQ,YAAY,CAAC;IACvC,OAAOA,YAAY;EACrB,CAAC,CAAC;AACJ;AAEA,SAASC,kBAAkBA,CAACE,IAAY,EAAU;EAChD,OAAOA,IAAI,CAACC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;AAChC;AAEA,SAASF,iBAAiBA,CAACC,IAAY,EAAU;EAC/C,OAAOA,IAAI,CAACC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;AAChC","ignoreList":[]}
@@ -17,22 +17,22 @@ function renderTemplate(template, manifest) {
17
17
  debug('manifest %o', manifest);
18
18
  return `
19
19
  <!DOCTYPE html>
20
- <html lang="en-us">
20
+ <html lang="en-us">
21
21
  <head>
22
22
  <meta charset="utf-8">
23
23
  <base href="${template === null || template === void 0 ? void 0 : template.options.base}">
24
- <title>${(_template$options$tit = template === null || template === void 0 || (_template$options = template.options) === null || _template$options === void 0 ? void 0 : _template$options.title) !== null && _template$options$tit !== void 0 ? _template$options$tit : ''}</title>
25
- <link rel="icon" href="${template === null || template === void 0 ? void 0 : template.options.base}/-/static/favicon.ico"/>
26
- <meta name="viewport" content="width=device-width, initial-scale=1" />
24
+ <title>${(_template$options$tit = template === null || template === void 0 || (_template$options = template.options) === null || _template$options === void 0 ? void 0 : _template$options.title) !== null && _template$options$tit !== void 0 ? _template$options$tit : ''}</title>
25
+ <link rel="icon" href="${template === null || template === void 0 ? void 0 : template.options.base}-/static/favicon.ico"/>
26
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
27
27
  <script>
28
28
  window.__VERDACCIO_BASENAME_UI_OPTIONS=${JSON.stringify(template.options)}
29
29
  </script>
30
30
  ${template !== null && template !== void 0 && template.metaScripts ? template.metaScripts.join('') : ''}
31
- </head>
31
+ </head>
32
32
  <body class="body">
33
- ${template !== null && template !== void 0 && template.scriptsbodyBefore ? template.scriptsbodyBefore.join('') : ''}
33
+ ${template !== null && template !== void 0 && template.scriptsbodyBefore ? template.scriptsbodyBefore.join('') : ''}
34
34
  <div id="root"></div>
35
- ${(0, _manifest.getManifestValue)(template.manifest.js, manifest, template === null || template === void 0 ? void 0 : template.options.base).map(item => `<script defer="defer" src="${item}"></script>`).join('')}
35
+ ${(0, _manifest.getManifestValue)(template.manifest.js, manifest, template === null || template === void 0 ? void 0 : template.options.base).map(item => `<script defer="defer" src="${item}"></script>`).join(`\n `)}
36
36
  ${template !== null && template !== void 0 && template.scriptsBodyAfter ? template.scriptsBodyAfter.join('') : ''}
37
37
  </body>
38
38
  </html>
@@ -1 +1 @@
1
- {"version":3,"file":"template.js","names":["_debug","_interopRequireDefault","require","_manifest","e","__esModule","default","debug","buildDebug","renderTemplate","template","manifest","_template$options$tit","_template$options","options","base","title","JSON","stringify","metaScripts","join","scriptsbodyBefore","getManifestValue","js","map","item","scriptsBodyAfter"],"sources":["../../../../src/middlewares/web/utils/template.ts"],"sourcesContent":["import buildDebug from 'debug';\n\nimport { TemplateUIOptions } from '@verdaccio/types';\n\nimport { Manifest, getManifestValue } from './manifest';\n\nconst debug = buildDebug('verdaccio:web:render:template');\n\nexport type Template = {\n manifest: Manifest;\n options: TemplateUIOptions;\n metaScripts?: string[];\n scriptsBodyAfter?: string[];\n scriptsbodyBefore?: string[];\n};\n\n// the outcome of the Webpack Manifest Plugin\nexport interface WebpackManifest {\n [key: string]: string;\n}\n\nexport default function renderTemplate(template: Template, manifest: WebpackManifest) {\n debug('template %o', template);\n debug('manifest %o', manifest);\n\n return `\n <!DOCTYPE html>\n <html lang=\"en-us\"> \n <head>\n <meta charset=\"utf-8\">\n <base href=\"${template?.options.base}\">\n <title>${template?.options?.title ?? ''}</title> \n <link rel=\"icon\" href=\"${template?.options.base}/-/static/favicon.ico\"/>\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" /> \n <script>\n window.__VERDACCIO_BASENAME_UI_OPTIONS=${JSON.stringify(template.options)}\n </script>\n ${template?.metaScripts ? template.metaScripts.join('') : ''}\n </head> \n <body class=\"body\">\n ${template?.scriptsbodyBefore ? template.scriptsbodyBefore.join('') : ''}\n <div id=\"root\"></div>\n ${getManifestValue(template.manifest.js, manifest, template?.options.base)\n .map((item) => `<script defer=\"defer\" src=\"${item}\"></script>`)\n .join('')}\n ${template?.scriptsBodyAfter ? template.scriptsBodyAfter.join('') : ''}\n </body>\n </html>\n `;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAIA,IAAAC,SAAA,GAAAD,OAAA;AAAwD,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAExD,MAAMG,KAAK,GAAG,IAAAC,cAAU,EAAC,+BAA+B,CAAC;;AAUzD;;AAKe,SAASC,cAAcA,CAACC,QAAkB,EAAEC,QAAy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CAAC,GAAG,EAAE;AAC9E;AACA;AACA,GAAG;AACH","ignoreList":[]}
1
+ {"version":3,"file":"template.js","names":["_debug","_interopRequireDefault","require","_manifest","e","__esModule","default","debug","buildDebug","renderTemplate","template","manifest","_template$options$tit","_template$options","options","base","title","JSON","stringify","metaScripts","join","scriptsbodyBefore","getManifestValue","js","map","item","scriptsBodyAfter"],"sources":["../../../../src/middlewares/web/utils/template.ts"],"sourcesContent":["import buildDebug from 'debug';\n\nimport { TemplateUIOptions } from '@verdaccio/types';\n\nimport { Manifest, getManifestValue } from './manifest';\n\nconst debug = buildDebug('verdaccio:web:render:template');\n\nexport type Template = {\n manifest: Manifest;\n options: TemplateUIOptions;\n metaScripts?: string[];\n scriptsBodyAfter?: string[];\n scriptsbodyBefore?: string[];\n};\n\n// the outcome of the Webpack Manifest Plugin\nexport interface WebpackManifest {\n [key: string]: string;\n}\n\nexport default function renderTemplate(template: Template, manifest: WebpackManifest) {\n debug('template %o', template);\n debug('manifest %o', manifest);\n\n return `\n <!DOCTYPE html>\n <html lang=\"en-us\">\n <head>\n <meta charset=\"utf-8\">\n <base href=\"${template?.options.base}\">\n <title>${template?.options?.title ?? ''}</title>\n <link rel=\"icon\" href=\"${template?.options.base}-/static/favicon.ico\"/>\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n <script>\n window.__VERDACCIO_BASENAME_UI_OPTIONS=${JSON.stringify(template.options)}\n </script>\n ${template?.metaScripts ? template.metaScripts.join('') : ''}\n </head>\n <body class=\"body\">\n ${template?.scriptsbodyBefore ? template.scriptsbodyBefore.join('') : ''}\n <div id=\"root\"></div>\n ${getManifestValue(template.manifest.js, manifest, template?.options.base)\n .map((item) => `<script defer=\"defer\" src=\"${item}\"></script>`)\n .join(`\\n `)}\n ${template?.scriptsBodyAfter ? template.scriptsBodyAfter.join('') : ''}\n </body>\n </html>\n `;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAIA,I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Q,CAAEI,OAAO,CAACC,IAAI,CAAC,CACvES,GAAG,CAAEC,IAAI,IAAK,8BAA8BA,IAAI,aAAa,CAAC,CAC9DL,IAAI,CAAC,YAAY,CAAC;AAC7B,UAAUV,QAAQ,aAARA,QAAQ,eAARA,QAAQ,CAAEgB,gBAAgB,GAAGhB,QAAQ,CAACgB,gBAAgB,CAACN,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE;AAC9E;AACA;AACA,GAAG;AACH","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdaccio/middleware",
3
- "version": "7.0.0-next-7.19",
3
+ "version": "7.0.0-next-7.20",
4
4
  "description": "express middleware utils",
5
5
  "main": "./build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -29,25 +29,25 @@
29
29
  "node": ">=12"
30
30
  },
31
31
  "dependencies": {
32
- "@verdaccio/core": "7.0.0-next-7.19",
33
- "@verdaccio/utils": "7.0.0-next-7.19",
34
- "@verdaccio/config": "7.0.0-next-7.19",
35
- "@verdaccio/url": "12.0.0-next-7.19",
32
+ "@verdaccio/config": "7.0.0-next-7.20",
33
+ "@verdaccio/core": "7.0.0-next-7.20",
34
+ "@verdaccio/url": "12.0.0-next-7.20",
35
+ "@verdaccio/utils": "7.0.0-next-7.20",
36
36
  "debug": "4.3.4",
37
- "lru-cache": "7.18.3",
38
37
  "express": "4.19.2",
38
+ "express-rate-limit": "5.5.1",
39
39
  "lodash": "4.17.21",
40
- "mime": "2.6.0",
41
- "express-rate-limit": "5.5.1"
40
+ "lru-cache": "7.18.3",
41
+ "mime": "2.6.0"
42
42
  },
43
43
  "funding": {
44
44
  "type": "opencollective",
45
45
  "url": "https://opencollective.com/verdaccio"
46
46
  },
47
47
  "devDependencies": {
48
- "@verdaccio/logger": "7.0.0-next-7.19",
48
+ "@verdaccio/logger": "7.0.0-next-7.20",
49
49
  "body-parser": "1.20.2",
50
- "supertest": "6.3.4"
50
+ "supertest": "7.0.0"
51
51
  },
52
52
  "scripts": {
53
53
  "clean": "rimraf ./build",
@@ -56,6 +56,7 @@
56
56
  "build:js": "babel src/ --out-dir build/ --copy-files --extensions \".ts,.tsx\" --source-maps",
57
57
  "watch": "pnpm build:js -- --watch",
58
58
  "test": "jest",
59
+ "test:snap": "jest --updateSnapshot",
59
60
  "build": "pnpm run build:js && pnpm run build:types"
60
61
  }
61
62
  }
@@ -16,8 +16,16 @@ export function getManifestValue(
16
16
  ): string[] {
17
17
  return manifestItems?.map((item) => {
18
18
  debug('resolve item %o', item);
19
- const resolvedItem = `${basePath}${manifest[item]}`;
19
+ const resolvedItem = `${stripTrailingSlash(basePath)}/${stripLeadingSlash(manifest[item])}`;
20
20
  debug('resolved item %o', resolvedItem);
21
21
  return resolvedItem;
22
22
  });
23
23
  }
24
+
25
+ function stripTrailingSlash(path: string): string {
26
+ return path.replace(/\/$/, '');
27
+ }
28
+
29
+ function stripLeadingSlash(path: string): string {
30
+ return path.replace(/^\//, '');
31
+ }
@@ -25,24 +25,24 @@ export default function renderTemplate(template: Template, manifest: WebpackMani
25
25
 
26
26
  return `
27
27
  <!DOCTYPE html>
28
- <html lang="en-us">
28
+ <html lang="en-us">
29
29
  <head>
30
30
  <meta charset="utf-8">
31
31
  <base href="${template?.options.base}">
32
- <title>${template?.options?.title ?? ''}</title>
33
- <link rel="icon" href="${template?.options.base}/-/static/favicon.ico"/>
34
- <meta name="viewport" content="width=device-width, initial-scale=1" />
32
+ <title>${template?.options?.title ?? ''}</title>
33
+ <link rel="icon" href="${template?.options.base}-/static/favicon.ico"/>
34
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
35
35
  <script>
36
36
  window.__VERDACCIO_BASENAME_UI_OPTIONS=${JSON.stringify(template.options)}
37
37
  </script>
38
38
  ${template?.metaScripts ? template.metaScripts.join('') : ''}
39
- </head>
39
+ </head>
40
40
  <body class="body">
41
- ${template?.scriptsbodyBefore ? template.scriptsbodyBefore.join('') : ''}
41
+ ${template?.scriptsbodyBefore ? template.scriptsbodyBefore.join('') : ''}
42
42
  <div id="root"></div>
43
43
  ${getManifestValue(template.manifest.js, manifest, template?.options.base)
44
44
  .map((item) => `<script defer="defer" src="${item}"></script>`)
45
- .join('')}
45
+ .join(`\n `)}
46
46
  ${template?.scriptsBodyAfter ? template.scriptsBodyAfter.join('') : ''}
47
47
  </body>
48
48
  </html>
@@ -3,22 +3,23 @@
3
3
  exports[`template custom body after 1`] = `
4
4
  "
5
5
  <!DOCTYPE html>
6
- <html lang="en-us">
6
+ <html lang="en-us">
7
7
  <head>
8
8
  <meta charset="utf-8">
9
- <base href="http://domain.com">
10
- <title></title>
9
+ <base href="http://domain.com/">
10
+ <title></title>
11
11
  <link rel="icon" href="http://domain.com/-/static/favicon.ico"/>
12
- <meta name="viewport" content="width=device-width, initial-scale=1" />
12
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
13
13
  <script>
14
- window.__VERDACCIO_BASENAME_UI_OPTIONS={"base":"http://domain.com"}
14
+ window.__VERDACCIO_BASENAME_UI_OPTIONS={"base":"http://domain.com/"}
15
15
  </script>
16
16
 
17
- </head>
17
+ </head>
18
18
  <body class="body">
19
-
19
+
20
20
  <div id="root"></div>
21
- <script defer="defer" src="http://domain.com/-/static/runtime.6126058572f989c948b1.js"></script><script defer="defer" src="http://domain.com/-/static/main.6126058572f989c948b1.js"></script>
21
+ <script defer="defer" src="http://domain.com/-/static/runtime.6126058572f989c948b1.js"></script>
22
+ <script defer="defer" src="http://domain.com/-/static/main.6126058572f989c948b1.js"></script>
22
23
  <script src="foo"/>
23
24
  </body>
24
25
  </html>
@@ -28,22 +29,23 @@ exports[`template custom body after 1`] = `
28
29
  exports[`template custom body before 1`] = `
29
30
  "
30
31
  <!DOCTYPE html>
31
- <html lang="en-us">
32
+ <html lang="en-us">
32
33
  <head>
33
34
  <meta charset="utf-8">
34
- <base href="http://domain.com">
35
- <title></title>
35
+ <base href="http://domain.com/">
36
+ <title></title>
36
37
  <link rel="icon" href="http://domain.com/-/static/favicon.ico"/>
37
- <meta name="viewport" content="width=device-width, initial-scale=1" />
38
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
38
39
  <script>
39
- window.__VERDACCIO_BASENAME_UI_OPTIONS={"base":"http://domain.com"}
40
+ window.__VERDACCIO_BASENAME_UI_OPTIONS={"base":"http://domain.com/"}
40
41
  </script>
41
42
 
42
- </head>
43
+ </head>
43
44
  <body class="body">
44
- <script src="fooBefore"/><script src="barBefore"/>
45
+ <script src="fooBefore"/><script src="barBefore"/>
45
46
  <div id="root"></div>
46
- <script defer="defer" src="http://domain.com/-/static/runtime.6126058572f989c948b1.js"></script><script defer="defer" src="http://domain.com/-/static/main.6126058572f989c948b1.js"></script>
47
+ <script defer="defer" src="http://domain.com/-/static/runtime.6126058572f989c948b1.js"></script>
48
+ <script defer="defer" src="http://domain.com/-/static/main.6126058572f989c948b1.js"></script>
47
49
 
48
50
  </body>
49
51
  </html>
@@ -53,22 +55,23 @@ exports[`template custom body before 1`] = `
53
55
  exports[`template custom render 1`] = `
54
56
  "
55
57
  <!DOCTYPE html>
56
- <html lang="en-us">
58
+ <html lang="en-us">
57
59
  <head>
58
60
  <meta charset="utf-8">
59
- <base href="http://domain.com">
60
- <title></title>
61
+ <base href="http://domain.com/">
62
+ <title></title>
61
63
  <link rel="icon" href="http://domain.com/-/static/favicon.ico"/>
62
- <meta name="viewport" content="width=device-width, initial-scale=1" />
64
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
63
65
  <script>
64
- window.__VERDACCIO_BASENAME_UI_OPTIONS={"base":"http://domain.com"}
66
+ window.__VERDACCIO_BASENAME_UI_OPTIONS={"base":"http://domain.com/"}
65
67
  </script>
66
68
 
67
- </head>
69
+ </head>
68
70
  <body class="body">
69
-
71
+
70
72
  <div id="root"></div>
71
- <script defer="defer" src="http://domain.com/-/static/runtime.6126058572f989c948b1.js"></script><script defer="defer" src="http://domain.com/-/static/main.6126058572f989c948b1.js"></script>
73
+ <script defer="defer" src="http://domain.com/-/static/runtime.6126058572f989c948b1.js"></script>
74
+ <script defer="defer" src="http://domain.com/-/static/main.6126058572f989c948b1.js"></script>
72
75
 
73
76
  </body>
74
77
  </html>
@@ -78,47 +81,23 @@ exports[`template custom render 1`] = `
78
81
  exports[`template custom title 1`] = `
79
82
  "
80
83
  <!DOCTYPE html>
81
- <html lang="en-us">
84
+ <html lang="en-us">
82
85
  <head>
83
86
  <meta charset="utf-8">
84
- <base href="http://domain.com">
85
- <title>foo title</title>
87
+ <base href="http://domain.com/">
88
+ <title>foo title</title>
86
89
  <link rel="icon" href="http://domain.com/-/static/favicon.ico"/>
87
- <meta name="viewport" content="width=device-width, initial-scale=1" />
90
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
88
91
  <script>
89
- window.__VERDACCIO_BASENAME_UI_OPTIONS={"base":"http://domain.com","title":"foo title"}
92
+ window.__VERDACCIO_BASENAME_UI_OPTIONS={"base":"http://domain.com/","title":"foo title"}
90
93
  </script>
91
94
 
92
- </head>
95
+ </head>
93
96
  <body class="body">
94
-
95
- <div id="root"></div>
96
- <script defer="defer" src="http://domain.com/-/static/runtime.6126058572f989c948b1.js"></script><script defer="defer" src="http://domain.com/-/static/main.6126058572f989c948b1.js"></script>
97
-
98
- </body>
99
- </html>
100
- "
101
- `;
102
-
103
- exports[`template custom title 2`] = `
104
- "
105
- <!DOCTYPE html>
106
- <html lang="en-us">
107
- <head>
108
- <meta charset="utf-8">
109
- <base href="http://domain.com">
110
- <title>foo title</title>
111
- <link rel="icon" href="http://domain.com/-/static/favicon.ico"/>
112
- <meta name="viewport" content="width=device-width, initial-scale=1" />
113
- <script>
114
- window.__VERDACCIO_BASENAME_UI_OPTIONS={"base":"http://domain.com","title":"foo title"}
115
- </script>
116
97
 
117
- </head>
118
- <body class="body">
119
-
120
98
  <div id="root"></div>
121
- <script defer="defer" src="http://domain.com/-/static/runtime.6126058572f989c948b1.js"></script><script defer="defer" src="http://domain.com/-/static/main.6126058572f989c948b1.js"></script>
99
+ <script defer="defer" src="http://domain.com/-/static/runtime.6126058572f989c948b1.js"></script>
100
+ <script defer="defer" src="http://domain.com/-/static/main.6126058572f989c948b1.js"></script>
122
101
 
123
102
  </body>
124
103
  </html>
@@ -128,22 +107,23 @@ exports[`template custom title 2`] = `
128
107
  exports[`template meta scripts 1`] = `
129
108
  "
130
109
  <!DOCTYPE html>
131
- <html lang="en-us">
110
+ <html lang="en-us">
132
111
  <head>
133
112
  <meta charset="utf-8">
134
- <base href="http://domain.com">
135
- <title></title>
113
+ <base href="http://domain.com/">
114
+ <title></title>
136
115
  <link rel="icon" href="http://domain.com/-/static/favicon.ico"/>
137
- <meta name="viewport" content="width=device-width, initial-scale=1" />
116
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
138
117
  <script>
139
- window.__VERDACCIO_BASENAME_UI_OPTIONS={"base":"http://domain.com"}
118
+ window.__VERDACCIO_BASENAME_UI_OPTIONS={"base":"http://domain.com/"}
140
119
  </script>
141
120
  <style>.someclass{font-size:10px;}</style>
142
- </head>
121
+ </head>
143
122
  <body class="body">
144
-
123
+
145
124
  <div id="root"></div>
146
- <script defer="defer" src="http://domain.com/-/static/runtime.6126058572f989c948b1.js"></script><script defer="defer" src="http://domain.com/-/static/main.6126058572f989c948b1.js"></script>
125
+ <script defer="defer" src="http://domain.com/-/static/runtime.6126058572f989c948b1.js"></script>
126
+ <script defer="defer" src="http://domain.com/-/static/main.6126058572f989c948b1.js"></script>
147
127
 
148
128
  </body>
149
129
  </html>
@@ -8,4 +8,16 @@ describe('manifest', () => {
8
8
  '/-/static/main.6126058572f989c948b1.js',
9
9
  ]);
10
10
  });
11
+
12
+ test('getManifestValue with base', () => {
13
+ expect(getManifestValue(['favicon.ico'], manifest, 'http://domain.com')).toEqual([
14
+ 'http://domain.com/-/static/favicon.ico',
15
+ ]);
16
+ });
17
+
18
+ test('getManifestValue with base with trailing slash', () => {
19
+ expect(getManifestValue(['favicon.ico'], manifest, 'http://domain.com/')).toEqual([
20
+ 'http://domain.com/-/static/favicon.ico',
21
+ ]);
22
+ });
11
23
  });
@@ -2,32 +2,27 @@ import template from '../src/middlewares/web/utils/template';
2
2
 
3
3
  const manifest = require('./partials/manifest/manifest.json');
4
4
 
5
+ // manifest expected to have leading slash
6
+ // see packages\middleware\test\partials\manifest\manifest.json
5
7
  const exampleManifest = {
6
8
  css: ['main.css'],
7
9
  js: ['runtime.js', 'main.js'],
8
- ico: '/static/foo.ico',
10
+ ico: 'favicon.ico',
9
11
  };
10
12
 
13
+ // "base" is expected to be result of getPublicUrl
14
+ // i.e. it must be valid URL with trailing slash
11
15
  describe('template', () => {
12
16
  test('custom render', () => {
13
17
  expect(
14
- template({ options: { base: 'http://domain.com' }, manifest: exampleManifest }, manifest)
18
+ template({ options: { base: 'http://domain.com/' }, manifest: exampleManifest }, manifest)
15
19
  ).toMatchSnapshot();
16
20
  });
17
21
 
18
22
  test('custom title', () => {
19
23
  expect(
20
24
  template(
21
- { options: { base: 'http://domain.com', title: 'foo title' }, manifest: exampleManifest },
22
- manifest
23
- )
24
- ).toMatchSnapshot();
25
- });
26
-
27
- test('custom title', () => {
28
- expect(
29
- template(
30
- { options: { base: 'http://domain.com', title: 'foo title' }, manifest: exampleManifest },
25
+ { options: { base: 'http://domain.com/', title: 'foo title' }, manifest: exampleManifest },
31
26
  manifest
32
27
  )
33
28
  ).toMatchSnapshot();
@@ -37,7 +32,7 @@ describe('template', () => {
37
32
  expect(
38
33
  template(
39
34
  {
40
- options: { base: 'http://domain.com' },
35
+ options: { base: 'http://domain.com/' },
41
36
  metaScripts: [`<style>.someclass{font-size:10px;}</style>`],
42
37
  manifest: exampleManifest,
43
38
  },
@@ -50,7 +45,7 @@ describe('template', () => {
50
45
  expect(
51
46
  template(
52
47
  {
53
- options: { base: 'http://domain.com' },
48
+ options: { base: 'http://domain.com/' },
54
49
  scriptsBodyAfter: [`<script src="foo"/>`],
55
50
  manifest: exampleManifest,
56
51
  },
@@ -63,7 +58,7 @@ describe('template', () => {
63
58
  expect(
64
59
  template(
65
60
  {
66
- options: { base: 'http://domain.com' },
61
+ options: { base: 'http://domain.com/' },
67
62
  scriptsbodyBefore: [`<script src="fooBefore"/>`, `<script src="barBefore"/>`],
68
63
  manifest: exampleManifest,
69
64
  },