Skip to content

Commit

Permalink
MWPW-158480 Exclude defaults from caas links (#2907)
Browse files Browse the repository at this point in the history
* MWPW-158480 Exclude defaults from caas links

* update version numb
  • Loading branch information
meganthecoder committed Sep 25, 2024
1 parent 969bc77 commit 3d1726d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions libs/blocks/caas-config/caas-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -827,10 +827,21 @@ const CopyBtn = () => {
}, 2000);
};

const removeDefaultsFromState = (fullState) => {
const reducedState = {};
Object.keys(fullState).forEach((key) => {
if (JSON.stringify(fullState[key]) !== JSON.stringify(defaultState[key])) {
reducedState[key] = fullState[key];
}
});
return reducedState;
};

const getUrl = async () => {
const url = new URL(window.location.href);
url.search = '';
const hashStr = await getEncodedObject(state, fgKeyReplacer);
const reducedState = removeDefaultsFromState(state);
const hashStr = await getEncodedObject(reducedState, fgKeyReplacer);
// starts with ~~ to differentiate from old hash format
url.hash = `~~${hashStr}`;
return url.href;
Expand All @@ -856,7 +867,7 @@ const CopyBtn = () => {
hour12: false,
});
const collectionName = state.collectionName ? `- ${state.collectionName} ` : '';
link.textContent = `Content as a Service v2 ${collectionName}- ${dateStr}${state.doNotLazyLoad ? ' (no-lazy)' : ''}`;
link.textContent = `Content as a Service v3 ${collectionName}- ${dateStr}${state.doNotLazyLoad ? ' (no-lazy)' : ''}`;

const blob = new Blob([link.outerHTML], { type: 'text/html' });
const data = [new ClipboardItem({ [blob.type]: blob })];
Expand Down
2 changes: 1 addition & 1 deletion test/blocks/caas-config/caas-config.test.html
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@
// The header is the part before the first / in the hash
// Due to this we only compare the characters after the header value

const hashWithoutHeader = 'bNhD9Lzw7Wafb9qCb7V0jBrxZN/aihyIoxuRIIkxxVHJor1L0vxek9ek4N+kNOR9v3gz/FaCUZk0WzFf8J6DnHTiovMj++jYTqrFQabk6LNbktvqMz2e07EWWg/E4E2DB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gAAAA==';

const hash = copyTextArea.value.split('#')[1].trim();

Expand Down

0 comments on commit 3d1726d

Please sign in to comment.