@adobe/spacecat-shared-tokowaka-client 1.3.1 → 1.3.2
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,10 @@
|
|
|
1
|
+
# [@adobe/spacecat-shared-tokowaka-client-v1.3.2](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-tokowaka-client-v1.3.1...@adobe/spacecat-shared-tokowaka-client-v1.3.2) (2025-12-11)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* tokowaka url header for preview ([#1235](https://github.com/adobe/spacecat-shared/issues/1235)) ([f265db8](https://github.com/adobe/spacecat-shared/commit/f265db821a9ea54809850e7fc771fdf3554f324f))
|
|
7
|
+
|
|
1
8
|
# [@adobe/spacecat-shared-tokowaka-client-v1.3.1](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-tokowaka-client-v1.3.0...@adobe/spacecat-shared-tokowaka-client-v1.3.1) (2025-12-10)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
|
@@ -138,14 +138,8 @@ export async function fetchHtmlWithWarmup(
|
|
|
138
138
|
|
|
139
139
|
// Parse the URL to extract path and construct full URL
|
|
140
140
|
const urlObj = new URL(url);
|
|
141
|
-
const urlPath = urlObj.pathname
|
|
142
|
-
|
|
143
|
-
// Add tokowakaPreview param for optimized HTML
|
|
141
|
+
const urlPath = urlObj.pathname;
|
|
144
142
|
let fullUrl = `${tokowakaEdgeUrl}${urlPath}`;
|
|
145
|
-
if (isOptimized) {
|
|
146
|
-
const separator = urlPath.includes('?') ? '&' : '?';
|
|
147
|
-
fullUrl = `${fullUrl}${separator}tokowakaPreview=true`;
|
|
148
|
-
}
|
|
149
143
|
|
|
150
144
|
const headers = {
|
|
151
145
|
'x-forwarded-host': forwardedHost,
|
|
@@ -153,6 +147,12 @@ export async function fetchHtmlWithWarmup(
|
|
|
153
147
|
'x-tokowaka-url': urlPath,
|
|
154
148
|
};
|
|
155
149
|
|
|
150
|
+
if (isOptimized) {
|
|
151
|
+
// Add tokowakaPreview param for optimized HTML
|
|
152
|
+
fullUrl = `${fullUrl}?tokowakaPreview=true`;
|
|
153
|
+
headers['x-tokowaka-url'] = `${urlPath}?tokowakaPreview=true`;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
156
|
const fetchOptions = {
|
|
157
157
|
method: 'GET',
|
|
158
158
|
headers,
|
|
@@ -123,7 +123,7 @@ describe('HTML Utils', () => {
|
|
|
123
123
|
expect(fetchStub.callCount).to.equal(2); // warmup + actual
|
|
124
124
|
});
|
|
125
125
|
|
|
126
|
-
it('should
|
|
126
|
+
it('should drop query parameters from URL when fetching optimized HTML', async () => {
|
|
127
127
|
fetchStub.resolves({
|
|
128
128
|
ok: true,
|
|
129
129
|
status: 200,
|
|
@@ -147,11 +147,11 @@ describe('HTML Utils', () => {
|
|
|
147
147
|
expect(html).to.equal('<html>Optimized HTML</html>');
|
|
148
148
|
expect(fetchStub.callCount).to.equal(2); // warmup + actual
|
|
149
149
|
|
|
150
|
-
// Verify
|
|
150
|
+
// Verify original query params are dropped and only tokowakaPreview is present
|
|
151
151
|
const actualUrl = fetchStub.secondCall.args[0];
|
|
152
|
-
expect(actualUrl).to.include('param=value');
|
|
153
|
-
expect(actualUrl).to.include('
|
|
154
|
-
expect(actualUrl).to.
|
|
152
|
+
expect(actualUrl).to.not.include('param=value');
|
|
153
|
+
expect(actualUrl).to.include('?tokowakaPreview=true');
|
|
154
|
+
expect(actualUrl).to.equal('https://edge.example.com/page?tokowakaPreview=true');
|
|
155
155
|
});
|
|
156
156
|
|
|
157
157
|
it('should throw error when HTTP response is not ok', async () => {
|