@adobe/helix-html-pipeline 3.7.11 → 3.8.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,3 +1,17 @@
1
+ ## [3.8.1](https://github.com/adobe/helix-html-pipeline/compare/v3.8.0...v3.8.1) (2023-01-15)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * ignore 'null' as header value ([#236](https://github.com/adobe/helix-html-pipeline/issues/236)) ([9f212f2](https://github.com/adobe/helix-html-pipeline/commit/9f212f2e9bafc57a33ed8e1203d18ac16bd4e6d7))
7
+
8
+ # [3.8.0](https://github.com/adobe/helix-html-pipeline/compare/v3.7.11...v3.8.0) (2023-01-13)
9
+
10
+
11
+ ### Features
12
+
13
+ * add contentbusId/path as surrogate key ([085e029](https://github.com/adobe/helix-html-pipeline/commit/085e029c5486e03871890ffc9fe52d9804f759d1))
14
+
1
15
  ## [3.7.11](https://github.com/adobe/helix-html-pipeline/compare/v3.7.10...v3.7.11) (2023-01-12)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-html-pipeline",
3
- "version": "3.7.11",
3
+ "version": "3.8.1",
4
4
  "description": "Helix HTML Pipeline",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -47,7 +47,7 @@
47
47
  "github-slugger": "2.0.0",
48
48
  "hast-util-raw": "7.2.3",
49
49
  "hast-util-select": "5.0.3",
50
- "hast-util-to-html": "8.0.3",
50
+ "hast-util-to-html": "8.0.4",
51
51
  "hast-util-to-string": "2.0.0",
52
52
  "hastscript": "7.2.0",
53
53
  "jose": "4.11.2",
@@ -81,12 +81,12 @@
81
81
  "@markedjs/html-differ": "4.0.2",
82
82
  "@semantic-release/changelog": "6.0.2",
83
83
  "@semantic-release/git": "10.0.1",
84
- "@semantic-release/npm": "9.0.1",
84
+ "@semantic-release/npm": "9.0.2",
85
85
  "c8": "7.12.0",
86
86
  "eslint": "8.31.0",
87
- "eslint-import-resolver-exports": "1.0.0-beta.3",
87
+ "eslint-import-resolver-exports": "1.0.0-beta.4",
88
88
  "eslint-plugin-header": "3.1.1",
89
- "eslint-plugin-import": "2.26.0",
89
+ "eslint-plugin-import": "2.27.4",
90
90
  "esmock": "2.1.0",
91
91
  "husky": "8.0.3",
92
92
  "js-yaml": "4.1.0",
package/src/json-pipe.js CHANGED
@@ -9,7 +9,7 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
- import { cleanupHeaderValue } from '@adobe/helix-shared-utils';
12
+ import { cleanupHeaderValue, computeSurrogateKey } from '@adobe/helix-shared-utils';
13
13
  import fetchConfigAll from './steps/fetch-config-all.js';
14
14
  import setCustomResponseHeaders from './steps/set-custom-response-headers.js';
15
15
  import { PipelineResponse } from './PipelineResponse.js';
@@ -112,8 +112,11 @@ export async function jsonPipe(state, req) {
112
112
  // set last-modified
113
113
  updateLastModified(state, response, extractLastModified(dataResponse.headers));
114
114
 
115
- // set surrogate key
116
- response.headers.set('x-surrogate-key', `${contentBusId}${path}`.replace(/\//g, '_'));
115
+ // set surrogate keys
116
+ const keys = [];
117
+ keys.push(`${contentBusId}${path}`.replace(/\//g, '_')); // TODO: remove
118
+ keys.push(await computeSurrogateKey(`${contentBusId}${path}`));
119
+ response.headers.set('x-surrogate-key', keys.join(' '));
117
120
 
118
121
  // Load config-all and set response headers
119
122
  await fetchConfigAll(state, req, response);
@@ -20,13 +20,25 @@ import { computeSurrogateKey } from '@adobe/helix-shared-utils';
20
20
  */
21
21
  export default async function setXSurrogateKeyHeader(state, req, res) {
22
22
  const {
23
- content, contentBusId, owner, repo, ref,
23
+ content, contentBusId, owner, repo, ref, info,
24
24
  } = state;
25
25
 
26
+ let { path } = info;
27
+
26
28
  const keys = [];
27
29
  if (content.sourceLocation) {
28
30
  keys.push(await computeSurrogateKey(content.sourceLocation));
29
31
  }
32
+
33
+ // surrogate key for path
34
+ // strip [index].plain.html
35
+ if (path.endsWith('index.plain.html')) {
36
+ path = path.substring(0, path.length - 'index.plain.html'.length);
37
+ } else if (path.endsWith('.plain.html')) {
38
+ path = path.substring(0, path.length - '.plain.html'.length);
39
+ }
40
+ keys.push(await computeSurrogateKey(`${contentBusId}${path}`));
41
+
30
42
  keys.push(`${contentBusId}_metadata`);
31
43
  keys.push(`${ref}--${repo}--${owner}_head`);
32
44
 
@@ -45,5 +45,9 @@ export function updateLastModified(state, res, httpDate) {
45
45
  * @return {string} the last modified date
46
46
  */
47
47
  export function extractLastModified(headers) {
48
- return headers.get('x-amz-meta-x-source-last-modified') ?? headers.get('last-modified');
48
+ const lastModified = headers.get('x-amz-meta-x-source-last-modified');
49
+ if (lastModified && lastModified !== 'null') {
50
+ return lastModified;
51
+ }
52
+ return headers.get('last-modified');
49
53
  }