@adobe/helix-html-pipeline 2.0.0 → 2.0.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/CHANGELOG.md CHANGED
@@ -1,3 +1,25 @@
1
+ ## [2.0.3](https://github.com/adobe/helix-html-pipeline/compare/v2.0.2...v2.0.3) (2022-05-30)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **deps:** update dependency @adobe/helix-markdown-support to v3.1.6 ([1dd999a](https://github.com/adobe/helix-html-pipeline/commit/1dd999a2c4ef3caf06a6b66dd7ff3e091166ea72))
7
+
8
+ ## [2.0.2](https://github.com/adobe/helix-html-pipeline/compare/v2.0.1...v2.0.2) (2022-05-28)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **deps:** update external fixes ([#65](https://github.com/adobe/helix-html-pipeline/issues/65)) ([0994581](https://github.com/adobe/helix-html-pipeline/commit/09945810ee3969350b6053d49d1614c1e9051eba))
14
+
15
+ ## [2.0.1](https://github.com/adobe/helix-html-pipeline/compare/v2.0.0...v2.0.1) (2022-05-25)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * querystring is deprecated ([d693319](https://github.com/adobe/helix-html-pipeline/commit/d6933197e928da452712bcfb2c8a42cdefe2bf2c))
21
+ * respect fragments and querystring during link-rewrite ([44e00d4](https://github.com/adobe/helix-html-pipeline/commit/44e00d49293df392f4dec7eafee1abc60743ff79))
22
+
1
23
  # [2.0.0](https://github.com/adobe/helix-html-pipeline/compare/v1.5.8...v2.0.0) (2022-05-25)
2
24
 
3
25
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-html-pipeline",
3
- "version": "2.0.0",
3
+ "version": "2.0.3",
4
4
  "description": "Helix HTML Pipeline",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -30,11 +30,11 @@
30
30
  "loader": "esmock"
31
31
  },
32
32
  "dependencies": {
33
- "@adobe/helix-markdown-support": "3.1.5",
33
+ "@adobe/helix-markdown-support": "3.1.6",
34
34
  "@adobe/helix-shared-utils": "2.0.10",
35
35
  "github-slugger": "1.4.0",
36
36
  "hast-util-raw": "7.2.1",
37
- "hast-util-select": "5.0.1",
37
+ "hast-util-select": "5.0.2",
38
38
  "hast-util-to-html": "8.0.3",
39
39
  "hast-util-to-string": "2.0.0",
40
40
  "hastscript": "7.0.2",
@@ -79,7 +79,7 @@
79
79
  "jsdoc-to-markdown": "7.1.1",
80
80
  "jsdom": "19.0.0",
81
81
  "junit-report-builder": "3.0.0",
82
- "lint-staged": "12.4.1",
82
+ "lint-staged": "12.4.2",
83
83
  "mocha": "10.0.0",
84
84
  "mocha-multi-reporters": "1.5.1",
85
85
  "remark-gfm": "3.0.1",
@@ -10,7 +10,6 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
  import mime from 'mime';
13
- import { parse } from 'querystring';
14
13
  import { h } from 'hastscript';
15
14
  import { visitParents } from 'unist-util-visit-parents';
16
15
 
@@ -22,10 +21,12 @@ const BREAK_POINTS = [
22
21
  export function createOptimizedPicture(src, alt = '', eager = false) {
23
22
  const url = new URL(src, 'https://localhost/');
24
23
  const { pathname, hash = '' } = url;
25
- let { width, height } = parse(hash.substring(1)); // intrinsic dimensions
24
+ const props = new URLSearchParams(hash.substring(1));
26
25
  // detect bug in media handler that created fragments like `width=800&width=600`
27
- if (Array.isArray(width)) {
28
- [width, height] = width;
26
+ // eslint-disable-next-line prefer-const
27
+ let [width, height] = props.getAll('width');
28
+ if (props.has('height')) {
29
+ height = props.get('height');
29
30
  }
30
31
  const ext = pathname.substring(pathname.lastIndexOf('.') + 1);
31
32
  const type = mime.getType(pathname);
@@ -201,15 +201,23 @@ export function rewriteUrl(state, url) {
201
201
  }
202
202
 
203
203
  if (HELIX_URL_REGEXP.test(url)) {
204
- const { pathname } = new URL(url);
205
- return pathname;
204
+ const { pathname, hash, search } = new URL(url);
205
+ if (hash && pathname === state.info?.path) {
206
+ return hash;
207
+ }
208
+ return `${pathname}${search}${hash}`;
206
209
  }
207
210
 
208
211
  // todo: read host from contentbus config
209
212
  if (state.config?.host) {
210
- const external = `https://${state.config.host}/`;
211
- if (url.startsWith(external)) {
212
- return url.substring(external.length - 1);
213
+ const {
214
+ host, pathname, search, hash,
215
+ } = new URL(url);
216
+ if (host === state.config.host) {
217
+ if (hash && pathname === state.info?.path) {
218
+ return hash;
219
+ }
220
+ return `${pathname}${search}${hash}`;
213
221
  }
214
222
  }
215
223