setModifyURLFunction
The setModifyURLFunction method allows you to define a custom function to modify URLs within the SDK.
This can be useful for adding query parameters, changing paths,
or any other URL transformations needed for your application.
By providing a function that takes a URL string as input and returns a modified URL string, you can control how URLs are handled by the SDK.
sdk.common.methods.setModifyURLFunction()setModifyURLFunction(modifyURL: ModifyURLFunction): Promise<Success>Parameters
modifyURLModifyURLFunction- A function that takes a URL string as input and returns a modified URL string.
Returns
Promise<Success>Usage example
Ensure the SDK is ready before setting the modify URL function.
function onSdkReady() {
window.gw.sdk.common.methods.setModifyURLFunction((url) => {
if (url.includes('products')) {
return url.replace('products', 'p');
} else {
return url;
}
});
}
if (window.gw && window.gw.sdk) {
onSdkReady();
} else {
document.addEventListener("gwSdkReady", onSdkReady);
}