Repository: Accenture/sfmc-devtools (js)

Issue:
[BUG] Mcdev strips content before and after script tag upon retrieval
### Is there an existing issue for this?

- [X] I have searched the existing issues

### Current Behavior

I recently tried pulling a code snippet, metadata would be asset. This code snippet contains html, ampscript and ssjs script. as of now, when retrieving such code snippets, all the content except the content within the ssjs tags would be lost

### Expected Behavior

_No response_

### Steps To Reproduce

1. Have a content block/code snippet with such content - including html, ampscript, ssjs within.
2. mcdev retrieve this asset using customer key
3. Done. When inspecting the file that has been retrieved, you'd find that the content before the `<script runat="server"> `tag is missing and the same with content after the `</script> `tag.

### Version

6.0.0

### Environment

MacOS, but this doesn't matter. Node and mcdev are of the latest versions. 

### Participation

- [X] I am willing to submit a pull request for this issue.

### Additional comments

_No response_

Pull request:
Bugfix/1157 mcdev strips content before and after script tag upon retrieval
# PR details

## What changes did you make? (Give an overview)

- closes #1157 

## Further details (optional)

...

## Checklist

- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] test scripts updated
- [-] Wiki updated (if applicable)


Patch:
diff --git a/lib/util/util.js b/lib/util/util.js
index 80d9ffcb..78585f1b 100644
--- a/lib/util/util.js
+++ b/lib/util/util.js
@@ -805,9 +805,9 @@ export const Util = {
         // \s*      whitespace characters, zero or more times
         // [^>]*?   any character that is not a >, zero or more times, un-greedily
         // (.*)     capture any character, zero or more times
-        // /ms      multiline and dotall flags
+        // /s      dotall flag
         // ideally the code looks like <script runat="server">...</script>
-        const scriptRegex = /^<\s*script [^>]*?>(.*)<\/\s*script\s*>$/ms;
+        const scriptRegex = /^<\s*script [^>]*?>(.*)<\/\s*script\s*>$/s;
         code = code.trim();
         const regexMatches = scriptRegex.exec(code);
         if (regexMatches?.length > 1) {


Test patch:
diff --git a/test/resourceFactory.js b/test/resourceFactory.js
index 7ef2fec6..30407d34 100644
--- a/test/resourceFactory.js
+++ b/test/resourceFactory.js
@@ -236,7 +236,9 @@ export const soapUrl =
 export const handleRESTRequest = async (config) => {
     try {
         // check if filtered
-        const urlObj = new URL(config.baseURL + config.url.slice(1));
+        const urlObj = new URL(
+            config.baseURL + (config.url.startsWith('/') ? config.url.slice(1) : config.url)
+        );
         let filterName;
         if (urlObj.searchParams.get('$filter')) {
             filterName = urlObj.searchParams.get('$filter').split(' eq ')[1];
diff --git a/test/resources/9999999/asset/block-1157-retrieve-expected.html b/test/resources/9999999/asset/block-1157-retrieve-expected.html
new file mode 100644
index 00000000..eec6813c
--- /dev/null
+++ b/test/resources/9999999/asset/block-1157-retrieve-expected.html
@@ -0,0 +1,13 @@
+<table cellpadding="0" cellspacing="0" width="100%" role="presentation" style="min-width: 100%; " class="stylingblock-content-wrapper"><tr><td class="stylingblock-content-wrapper camarker-inner"><div>
+  my 1st html
+</div>
+%%[
+    /* my ampscript */
+]%%
+<script runat="server">
+// my ssjs
+</script>
+
+<div>
+  my 2nd html
+</div></td></tr></table>
\ No newline at end of file
diff --git a/test/resources/9999999/asset/block-1157-retrieve-expected.json b/test/resources/9999999/asset/block-1157-retrieve-expected.json
new file mode 100644
index 00000000..7ce3e8ee
--- /dev/null
+++ b/test/resources/9999999/asset/block-1157-retrieve-expected.json
@@ -0,0 +1,41 @@
+{
+    "customerKey": "mcdev-issue-1157",
+    "assetType": {
+        "name": "htmlblock",
+        "displayName": "HTML Block"
+    },
+    "fileProperties": {
+        "fileName": "mcdev-issue-1157-Mcdev-strips-content"
+    },
+    "name": "mcdev-issue-1157-Mcdev-strips-content",
+    "owner": {
+        "email": "joern.berkefeld@accenture.com",
+        "name": "Jörn Berkefeld (ASGR)"
+    },
+    "createdDate": "2024-01-08T08:26:58.277-06:00",
+    "createdBy": {
+        "email": "joern.berkefeld@accenture.com",
+        "name": "Jörn Berkefeld (ASGR)"
+    },
+    "modifiedDate": "2024-01-08T08:28:01.6-06:00",
+    "modifiedBy": {
+        "email": "joern.berkefeld@accenture.com",
+        "name": "Jörn Berkefeld (ASGR)"
+    },
+    "memberId": 9999999,
+    "status": {
+        "name": "Draft"
+    },
+    "design": "",
+    "meta": {
+        "wrapperStyles": {
+            "mobile": {
+                "visible": true
+            },
+            "styling": {}
+        }
+    },
+    "availableViews": [],
+    "modelVersion": 2,
+    "r__folder_Path": "Content Builder"
+}
diff --git a/test/resources/9999999/asset/v1/content/assets/1209971/get-response.json b/test/resources/9999999/asset/v1/content/assets/1209971/get-response.json
new file mode 100644
index 00000000..7b01d732
--- /dev/null
+++ b/test/resources/9999999/asset/v1/content/assets/1209971/get-response.json
@@ -0,0 +1,61 @@
+{
+    "customerKey": "mobileMessage_test",
+    "assetType": {
+        "name": "jsonmessage",
+        "displayName": "JSON Message"
+    },
+    "name": "Mobile Message November 22, 2021(4:20:55 PM)",
+    "owner": {
+        "email": "joern.berkefeld@accenture.com",
+        "name": "Jörn Berkefeld"
+    },
+    "createdDate": "2021-11-22T09:21:11.933-06:00",
+    "createdBy": {
+        "email": "joern.berkefeld@accenture.com",
+        "name": "Jörn Berkefeld"
+    },
+    "modifiedDate": "2021-12-16T02:56:24.29-06:00",
+    "modifiedBy": {
+        "name": "SFMC DEVOPS app user"
+    },
+    "memberId": 9999999,
+    "status": {
+        "name": "Draft"
+    },
+    "views": {
+        "push": {
+            "thumbnail": {},
+            "content": "<!doctype html>\n<html>\n\t<head>\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n\t\t<meta name=\"description\" content=\"Push Preview\">\n\t\t<style>\n\thtml,\n\tbody {\n\t\tmargin: 0;\n\t\tpadding: 0;\n\t\theight: 100%;\n\t\twidth: 100%;\n\t\tline-height: 1.4;\n\t}\n\n\t.push-previewer {\n\t\twidth: inherit;\n\t\theight: inherit;\n\t\tposition: relative;\n\t}\n\n\t.device {\n\t\theight: inherit;\n\t\twidth: inherit;\n\t\tbackground-size: cover;\n\t\tbackground-repeat: no-repeat;\n\t}\n</style> <style>\n\t@font-face {\n\t\tfont-family: 'SF Pro Text - Regular';\n\t\tsrc: url('https://mobilepush-device-previewer.s7.marketingcloudapps.com/fonts/SFProText-Regular.woff') format('woff');\n\t\tfont-weight: normal;\n\t\tfont-style: normal;\n\t}\n\t\n\t@font-face {\n\t\tfont-family: 'Helvetica Neue - Roman';\n\t\tsrc: url('https://mobilepush-device-previewer.s7.marketingcloudapps.com/fonts/HelveticaNeue-Roman.woff') format('woff');\n\t\tfont-weight: normal;\n\t\tfont-style: normal;\n\t}\n\t\n\t@font-face {\n\t\tfont-family: 'SF Compact Text - Light';\n\t\tsrc: url('https://mobilepush-device-previewer.s7.marketingcloudapps.com/fonts/SFCompactText-Light.woff') format('woff');\n\t\tfont-weight: normal;\n\t\tfont-style: normal;\n\t}\n\t\n\t.device.iphone.lock-screen {\n\t\tfont-family: 'SF Pro Text - Regular';\n\t\tbackground-image: url('https://image.s8.exacttarget.com/lib/fe8e1c72746d057a70/m/1/d1948d1e-93af-4b9d-8b28-a087a351e8a8.jpg');\n\t}\n\t\n\t.device.iphone.lock-screen .header {\n\t\ttext-align: center;\n\t\tmargin-bottom: 20px;\n\t}\n\t\n\t.device.iphone.lock-screen .header .time {\n\t\tcolor: #FFFFFF;\n\t\tfont-family: 'SF Compact Text - Light';\n\t\tfont-size: 60px;\n\t\theight: 70px;\n\t}\n\n\t.device.iphone.lock-screen .header .date {\n\t\tcolor: #FFFFFF;\n\t\tfont-family: 'Helvetica Neue - Roman';\n\t\tfont-size: 17px;\n\t}\n\t\n\t.device.iphone.lock-screen .body {\n\t\tbackground: rgba(240, 240, 240, 0.97);\n\t\tborder-radius: 12px;\n\t\tpadding: 10px;\n\t\tmargin: 0 4px;\n\t\topacity: 1;\n\t\tposition: relative;\n\t}\n\t\n\t.device.iphone.lock-screen .body .application {\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\tborder-radius: 12px 12px 0 0;\n\t\tbackground: #F0F0F0;\n\t\tmargin: -10px -10px 0 -10px;\n\t\tpadding: 10px;\n\t}\n\t\n\t.device.iphone.lock-screen .body .application .icon {\n\t\t\n\t}\n\t\n\t.device.iphone.lock-screen .body .application .icon .icon-placeholder {\n\t\theight: 17px;\n\t\twidth: 17px;\n\t\tborder-radius: 3px;\n\t\tbackground-color: grey;\n\t\tdisplay: inline-block;\n\t\tvertical-align: middle;\n\t}\n\t\n\t.device.iphone.lock-screen .body .application .name {\n\t\tcolor: #000000;\n\t\topacity: .50;\n\t\tfont-size: 12px;\n\t\ttext-overflow: ellipsis;\n\t\toverflow: hidden;\n\t\twhite-space: nowrap;\n\t\twidth: 100%;\n\t\tpadding: 2px 5px 0 10px;\n\t}\n\t\n\t.device.iphone.lock-screen .body .application .timestamp {\n\t\tfont-size: 11px;\n\t\topacity: .50;\n\t\tfont-weight: bold;\n\t\tmargin-left: auto;\n\t}\n\t\n\t.device.iphone.lock-screen .body .media {\n\t\tborder-radius: 3px;\n\t\twidth: 26px;\n\t\theight: 26px;\n\t\tposition: absolute;\n\t\tright: 10px;\n\t\tbottom: 10px;\n\t}\n\t\n\t.device.iphone.lock-screen .body .media img {\n\t\theight: 100%;\n\t\tmax-height: 26px;\n\t\twidth: 100%;\n\t\tmax-width: 26px;\n\t}\n\t\n\t.device.iphone.lock-screen .body .content {\n\t\tcolor: #000000;\n\t\tfont-size: 13px;\n\t\tpadding-top: 5px;\n\t}\n\t\n\t.device.iphone.lock-screen .body .content > div {\n\t\ttext-overflow: ellipsis;\n\t\toverflow: hidden;\n\t}\n\t\n\t.device.iphone.lock-screen .body .content .title {\n\t\tfont-weight: bold;\n\t\twhite-space: nowrap;\n\t}\n\t\n\t.device.iphone.lock-screen .body .content .subtitle {\n\t\tfont-weight: bold;\n\t\twhite-space: nowrap;\n\t}\n\t\n\t.device.iphone.lock-screen .body .content .message {\n\t\twhite-space: pre-wrap;\n\t\tdisplay: -webkit-box;\n\t\t-webkit-line-clamp: 4;\n\t\t-webkit-box-orient: vertical;\n\t\ttext-overflow: ellipsis;\n\t\t-o-text-overflow: ellipsis;\n\t\t-ms-text-overflow: ellipsis;\n\t\tword-break: break-word;\n\t\t-ms-word-wrap: break-word;\n\t\tword-wrap: break-word;\n\t\tmax-height: 75px;\n\t}\n\t\n\t.device.iphone.lock-screen .body .content .message.hasTitle {\n\t\tmax-height: 55px;\n\t\t-webkit-line-clamp: 3;\n\t}\n\t\n\t.device.iphone.lock-screen .body .content .message.hasSubtitle {\n\t\tmax-height: 35px;\n\t\t-webkit-line-clamp: 2;\n\t}\n\t\n\t.device.iphone.lock-screen .body .content.hasMedia .message {\n\t\tpadding-right: 50px;\n\t}\n\t\n\t.device.iphone.lock-screen .body .action {\n\t\tcolor: #157EBF;\n\t\tfont-size: 11px;\n\t\topacity: .3;\n\t\tmargin-top: 5px;\n\t}\n\t\n\t.device.iphone.lock-screen .body .buttons {\n\t\tdisplay: none;\n\t}\n\t\n\t.device.iphone.lock-screen .footer {\n\t\tdisplay: none;\n\t}\n</style>\n\t</head>\n\t<body>\n\t\t<div class=\"push-previewer\">\n\t\t\t<div class=\"device iphone lock-screen\">\n\t\t\t\t<div class=\"header\">\n\t\t\t\t\t<div class=\"time\">12:00 AM</div>\n\t\t\t\t\t<div class=\"date\">January 1, 2020</div>\n\t\t\t\t</div>\n\t\t\t\t<div class=\"body\">\n\t\t\t\t\t<div class=\"application\">\n\t\t\t\t\t\t<div class=\"icon\">\n\t\t\t\t\t\t\t<div class=\"icon-placeholder\"></div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class=\"name\">App Name</div>\n\t\t\t\t\t\t<div class=\"timestamp\">now</div>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"media\"></div>\n\t\t\t\t\t<div class=\"content \">\n\t\t\t\t\t\t<div class=\"title\">test</div>\n\t\t\t\t\t\t<div class=\"subtitle\"></div>\n\t\t\t\t\t\t<div class=\"message hasTitle \">asdfasf </div>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"action\"></div>\n\t\t\t\t\t<div class=\"buttons\">\n\t\t\t\t\t\t<div class=\"button1\"></div>\n\t\t\t\t\t\t<div class=\"button2\"></div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t\t<div class=\"footer\"></div>\n\t\t\t</div>\n\t\t</div>\n\t</body>\n</html>",
+            "meta": {
+                "options": {
+                    "customBlockData": {
+                        "display:title": "test",
+                        "channel": "push",
+                        "showTemplatePicker": false,
+                        "display:title:display": "test",
+                        "stack": "S7",
+                        "openBehavior:actionType": {
+                            "label": "Open the App",
+                            "value": "openApp",
+                            "id": "openApp_0",
+                            "localizedLabel": "Open the App"
+                        },
+                        "display:message": "asdfasf ",
+                        "currentColumn": 0,
+                        "display:message:display": "asdfasf ",
+                        "template": "push",
+                        "uncheckedPanels": ["pushmedia", "subtitle"]
+                    }
+                }
+            },
+            "modelVersion": 2
+        }
+    },
+    "availableViews": ["push"],
+    "modelVersion": 2,
+    "category": {
+        "id": 89397,
+        "name": "Content Builder",
+        "parentId": 0
+    }
+}
diff --git a/test/resources/9999999/asset/v1/content/assets/1295064/get-response.json b/test/resources/9999999/asset/v1/content/assets/1295064/get-response.json
new file mode 100644
index 00000000..ffa82c77
--- /dev/null
+++ b/test/resources/9999999/asset/v1/content/assets/1295064/get-response.json
@@ -0,0 +1,60 @@
+{
+    "id": 1295064,
+    "customerKey": "mcdev-issue-1157",
+    "objectID": "972974ed-dc44-4df2-ab6e-53bae9070339",
+    "assetType": {
+        "id": 197,
+        "name": "htmlblock",
+        "displayName": "HTML Block"
+    },
+    "fileProperties": {
+        "fileName": "mcdev-issue-1157-Mcdev-strips-content"
+    },
+    "name": "mcdev-issue-1157-Mcdev-strips-content",
+    "owner": {
+        "id": 700301950,
+        "email": "joern.berkefeld@accenture.com",
+        "name": "Jörn Berkefeld (ASGR)",
+        "userId": "700301950"
+    },
+    "createdDate": "2024-01-08T08:26:58.277-06:00",
+    "createdBy": {
+        "id": 700301950,
+        "email": "joern.berkefeld@accenture.com",
+        "name": "Jörn Berkefeld (ASGR)",
+        "userId": "700301950"
+    },
+    "modifiedDate": "2024-01-08T08:28:01.6-06:00",
+    "modifiedBy": {
+        "id": 700301950,
+        "email": "joern.berkefeld@accenture.com",
+        "name": "Jörn Berkefeld (ASGR)",
+        "userId": "700301950"
+    },
+    "enterpriseId": 9999999,
+    "memberId": 9999999,
+    "status": {
+        "id": 1,
+        "name": "Draft"
+    },
+    "thumbnail": {
+        "thumbnailUrl": "/v1/assets/1295064/thumbnail"
+    },
+    "category": {
+        "id": 89397,
+        "name": "Content Builder",
+        "parentId": 0
+    },
+    "content": "<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" role=\"presentation\" style=\"min-width: 100%; \" class=\"stylingblock-content-wrapper\"><tr><td class=\"stylingblock-content-wrapper camarker-inner\"><div>\n  my 1st html\n</div>\n\n%%[ /* my ampscript */ ]%%\n\n<script runat=\"server\">\n// my ssjs\n</script>\n\n<div>\n  my 2nd html\n</div></td></tr></table>",
+    "design": "",
+    "meta": {
+        "wrapperStyles": {
+            "mobile": {
+                "visible": true
+            },
+            "styling": {}
+        }
+    },
+    "availableViews": [],
+    "modelVersion": 2
+}
diff --git a/test/resources/9999999/asset/v1/content/assets/808714/get-response.json b/test/resources/9999999/asset/v1/content/assets/808714/get-response.json
new file mode 100644
index 00000000..a93eeb69
--- /dev/null
+++ b/test/resources/9999999/asset/v1/content/assets/808714/get-response.json
@@ -0,0 +1,184 @@
+{
+    "id": 808714,
+    "customerKey": "testExisting_asset_message",
+    "objectID": "01f883be-c5c3-4eb1-b6e1-d7036f8153d4",
+    "contentType": "application/vnd.etmc.email.Message; kind=paste",
+    "assetType": {
+        "id": 208,
+        "name": "htmlemail",
+        "displayName": "HTML Email"
+    },
+    "name": "testExisting_asset_message",
+    "owner": {
+        "id": 717129834,
+        "email": "joern.berkefeld@accenture.com",
+        "name": "Jörn Berkefeld",
+        "userId": "717129834"
+    },
+    "createdDate": "2020-03-06T02:35:15.677-06:00",
+    "createdBy": {
+        "id": 717129834,
+        "email": "joern.berkefeld@accenture.com",
+        "name": "Jörn Berkefeld",
+        "userId": "717129834"
+    },
+    "modifiedDate": "2023-08-02T07:08:00.86-06:00",
+    "modifiedBy": {
+        "id": 700304523,
+        "name": "SFMC DEVOPS app user",
+        "userId": "700304523"
+    },
+    "enterpriseId": 7281698,
+    "memberId": 7281698,
+    "status": {
+        "id": 1,
+        "name": "Draft"
+    },
+    "thumbnail": {
+        "thumbnailUrl": "/v1/assets/808714/thumbnail"
+    },
+    "category": {
+        "id": 89397,
+        "name": "Content Builder",
+        "parentId": 0
+    },
+    "views": {
+        "subjectline": {
+            "contentType": "application/vnd.etmc.email.View; kind=subjectline",
+            "thumbnail": {},
+            "content": "TEST",
+            "availableViews": [],
+            "data": {
+                "email": {
+                    "options": {
+                        "generateFrom": null
+                    }
+                }
+            },
+            "modelVersion": 2
+        },
+        "preheader": {
+            "thumbnail": {},
+            "availableViews": [],
+            "data": {
+                "email": {
+                    "options": {
+                        "generateFrom": null
+                    }
+                }
+            },
+            "modelVersion": 2
+        },
+        "html": {
+            "thumbnail": {},
+            "content": "<a href=\"%%ftaf_url%%\"\n    ><img\n        src=\"https://www.exacttarget.com/members/newsletters/gfx/forwardafriendicon.gif\"\n        border=\"0\" /></a\n><a href=\"%%profile_center_url%%\" alias=\"Update Profile\">Update Profile</a>\n<table cellpadding=\"2\" cellspacing=\"0\" width=\"600\" id=\"Table5\" border=\"0\">\n    <tr>\n        <td>\n            <font face=\"verdana\" size=\"1\" color=\"#444444\"\n                >This email was sent by: <b>%%Member_Busname%%</b><br />%%Member_Addr%%\n                %%Member_City%%, %%Member_State%%, %%Member_PostalCode%%, %%Member_Country%%<br /><br\n            /></font>\n        </td>\n    </tr>\n</table>\n<a href=\"%%subscription_center_url%%\" alias=\"Manage Subscriptions\">Manage Subscriptions</a\n><img src=\"https://www.exacttarget.com/images/Powered_By_1206.jpg\" border=\"0\" /><custom\n    name=\"opencounter\"\n    type=\"tracking\"\n/>\n",
+            "availableViews": [],
+            "data": {
+                "email": {
+                    "options": {
+                        "generateFrom": null
+                    }
+                }
+            },
+            "modelVersion": 2
+        },
+        "text": {
+            "thumbnail": {},
+            "availableViews": [],
+            "data": {
+                "email": {
+                    "options": {
+                        "generateFrom": "html"
+                    }
+                }
+            },
+            "generateFrom": "html",
+            "modelVersion": 2
+        },
+        "viewAsAWebPage": {
+            "thumbnail": {},
+            "availableViews": [],
+            "data": {
+                "email": {
+                    "options": {
+                        "generateFrom": null
+                    }
+                }
+            },
+            "modelVersion": 2
+        },
+        "subscriptioncenter": {
+            "thumbnail": {},
+            "availableViews": [],
+            "data": {
+                "email": {
+                    "options": {
+                        "generateFrom": null
+                    }
+                }
+            },
+            "modelVersion": 2
+        },
+        "forwardHTML": {
+            "thumbnail": {},
+            "availableViews": [],
+            "data": {
+                "email": {
+                    "options": {
+                        "generateFrom": null
+                    }
+                }
+            },
+            "modelVersion": 2
+        },
+        "forwardText": {
+            "thumbnail": {},
+            "availableViews": [],
+            "data": {
+                "email": {
+                    "options": {
+                        "generateFrom": null
+                    }
+                }
+            },
+            "modelVersion": 2
+        }
+    },
+    "availableViews": [
+        "subjectline",
+        "preheader",
+        "html",
+        "text",
+        "viewAsAWebPage",
+        "subscriptioncenter",
+        "forwardHTML",
+        "forwardText"
+    ],
+    "data": {
+        "email": {
+            "options": {
+                "characterEncoding": "utf-8"
+            },
+            "legacy": {
+                "legacyId": 429827,
+                "legacyKey": "c7308370-bb2c-4bd4-83dd-0ea422e2009d",
+                "legacyType": "email",
+                "legacyCategoryId": 90890
+            }
+        },
+        "approvals": {
+            "approvalStatus": {
+                "id": 4,
+                "name": "Approved",
+                "displayName": "Approved"
+            }
+        }
+    },
+    "legacyData": {
+        "legacyId": 429827,
+        "legacyKey": "c7308370-bb2c-4bd4-83dd-0ea422e2009d",
+        "legacyType": "email",
+        "legacyCategoryId": 90890
+    },
+    "modelVersion": 2
+}
diff --git a/test/resources/9999999/asset/v1/content/assets/query/post-response.json b/test/resources/9999999/asset/v1/content/assets/query/post-response.json
index 7bb8d6ea..864d9b96 100644
--- a/test/resources/9999999/asset/v1/content/assets/query/post-response.json
+++ b/test/resources/9999999/asset/v1/content/assets/query/post-response.json
@@ -23,7 +23,7 @@
                 "userId": "700304523"
             },
             "status": { "id": 1, "name": "Draft" },
-            "category": { "id": 290833, "name": "Content Builder", "parentId": 0 },
+            "category": { "id": 89397, "name": "Content Builder", "parentId": 0 },
             "availableViews": ["html", "text", "subjectline", "preheader"],
             "data": {
                 "email": {
@@ -64,9 +64,47 @@
                 "userId": "700301950"
             },
             "status": { "id": 1, "name": "Draft" },
-            "category": { "id": 283608, "name": "Content Builder", "parentId": 0 },
+            "category": { "id": 89397, "name": "Content Builder", "parentId": 0 },
             "availableViews": ["push"],
             "modelVersion": 2
+        },
+        {
+            "id": 1295064,
+            "customerKey": "mcdev-issue-1157",
+            "assetType": {
+                "id": 197,
+                "name": "htmlblock",
+                "displayName": "HTML Block"
+            },
+            "fileProperties": {
+                "fileName": "dont strip non ssjs content"
+            },
+            "name": "dont strip non ssjs content",
+            "createdDate": "2024-01-08T08:26:58.277-06:00",
+            "createdBy": {
+                "id": 700301950,
+                "email": "joern.berkefeld@accenture.com",
+                "name": "Jörn Berkefeld (ASGR)",
+                "userId": "700301950"
+            },
+            "modifiedDate": "2024-01-08T08:28:01.6-06:00",
+            "modifiedBy": {
+                "id": 700301950,
+                "email": "joern.berkefeld@accenture.com",
+                "name": "Jörn Berkefeld (ASGR)",
+                "userId": "700301950"
+            },
+            "status": {
+                "id": 1,
+                "name": "Draft"
+            },
+            "category": {
+                "id": 89397,
+                "name": "Content Builder",
+                "parentId": 0
+            },
+            "availableViews": [],
+            "modelVersion": 2
         }
     ]
 }
diff --git a/test/resources/9999999/dataFolder/retrieve-ContentType=asset-sharedORContentType=asset-response.xml b/test/resources/9999999/dataFolder/retrieve-ContentType=asset-sharedORContentType=asset-response.xml
new file mode 100644
index 00000000..4898884b
--- /dev/null
+++ b/test/resources/9999999/dataFolder/retrieve-ContentType=asset-sharedORContentType=asset-response.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="utf-8"?>
+<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+    xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
+    xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
+    xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
+    <soap:Header>
+        <wsa:Action>RetrieveResponse</wsa:Action>
+        <wsa:MessageID>urn:uuid:00106553-ac00-4e72-b387-42325fe6f93d</wsa:MessageID>
+        <wsa:RelatesTo>urn:uuid:a1dd2a9d-b696-480e-9a1b-265f262a8997</wsa:RelatesTo>
+        <wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To>
+        <wsse:Security>
+            <wsu:Timestamp wsu:Id="Timestamp-d82724f8-afc2-4461-8e3e-190aeb6d9625">
+                <wsu:Created>2024-01-08T14:30:39Z</wsu:Created>
+                <wsu:Expires>2024-01-08T14:35:39Z</wsu:Expires>
+            </wsu:Timestamp>
+        </wsse:Security>
+    </soap:Header>
+    <soap:Body>
+        <RetrieveResponseMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
+            <OverallStatus>OK</OverallStatus>
+            <RequestID>6596087d-d12f-4c9d-9353-783fe01775a3</RequestID>
+            <Results xsi:type="DataFolder">
+                <Client>
+                    <ID>9999999</ID>
+                </Client>
+                <PartnerKey xsi:nil="true" />
+                <CreatedDate>2016-07-22T11:52:35.687</CreatedDate>
+                <ModifiedDate>2016-07-22T11:52:35.687</ModifiedDate>
+                <ID>89397</ID>
+                <ObjectID xsi:nil="true" />
+                <CustomerKey />
+                <ParentFolder>
+                    <PartnerKey xsi:nil="true" />
+                    <ID>0</ID>
+                    <ObjectID xsi:nil="true" />
+                </ParentFolder>
+                <Name>Content Builder</Name>
+                <Description>The root folder for assets</Description>
+                <ContentType>asset</ContentType>
+                <IsActive>true</IsActive>
+                <IsEditable>false</IsEditable>
+                <AllowChildren>true</AllowChildren>
+            </Results>
+            <Results xsi:type="DataFolder">
+                <Client>
+                    <ID>9999999</ID>
+                </Client>
+                <PartnerKey xsi:nil="true" />
+                <CreatedDate>2016-07-29T12:13:07.7</CreatedDate>
+                <ModifiedDate>2021-12-16T02:56:14.68</ModifiedDate>
+                <ID>90888</ID>
+                <ObjectID xsi:nil="true" />
+                <CustomerKey />
+                <ParentFolder>
+                    <PartnerKey xsi:nil="true" />
+                    <ID>89397</ID>
+                    <ObjectID xsi:nil="true" />
+                </ParentFolder>
+                <Name>Test Folder</Name>
+                <Description />
+                <ContentType>asset</ContentType>
+                <IsActive>true</IsActive>
+                <IsEditable>true</IsEditable>
+                <AllowChildren>true</AllowChildren>
+            </Results>
+        </RetrieveResponseMsg>
+    </soap:Body>
+</soap:Envelope>
diff --git a/test/type.asset.test.js b/test/type.asset.test.js
new file mode 100644
index 00000000..df709ace
--- /dev/null
+++ b/test/type.asset.test.js
@@ -0,0 +1,84 @@
+import File from '../lib/util/file.js';
+
+import chai, { assert, expect } from 'chai';
+import chaiFiles from 'chai-files';
+import cache from '../lib/util/cache.js';
+import * as testUtils from './utils.js';
+import handler from '../lib/index.js';
+chai.use(chaiFiles);
+const file = chaiFiles.file;
+
+/**
+ * gets file from Retrieve folder
+ *
+ * @param {string} customerKey of metadata
+ * @param {string} type of metadata
+ * @param {string} subtype of metadata
+ * @param {string} [buName] used when we need to test on ParentBU
+ * @returns {Promise.<string>} file in string form
+ */
+function getActualJson(customerKey, type, subtype, buName = 'testBU') {
+    return File.readJSON(
+        `./retrieve/testInstance/${buName}/${type}/${subtype}/${customerKey}.${type}-${subtype}-meta.json`
+    );
+}
+/**
+ * gets file from Retrieve folder
+ *
+ * @param {string} customerKey of metadata
+ * @param {string} type of metadata
+ * @param {string} subtype of metadata
+ * @param {string} ext file extension
+ * @returns {string} file path
+ */
+function getActualFile(customerKey, type, subtype, ext) {
+    return `./retrieve/testInstance/testBU/${type}/${subtype}/${customerKey}.${type}-${subtype}-meta.${ext}`;
+}
+
+describe('type: asset', () => {
+    beforeEach(() => {
+        testUtils.mockSetup();
+    });
+    afterEach(() => {
+        testUtils.mockReset();
+    });
+    describe('Retrieve ================', () => {
+        it('Should retrieve a asset & ensure non-ssjs code is not removed', async () => {
+            // WHEN
+            const retrieve = await handler.retrieve('testInstance/testBU', ['asset']);
+
+            // THEN
+            assert.equal(process.exitCode, false, 'retrieve should not have thrown an error');
+            assert.equal(
+                retrieve['testInstance/testBU'].asset
+                    ? Object.keys(retrieve['testInstance/testBU'].asset).length
+                    : 0,
+                3,
+                'only 3 assets expected in retrieve response'
+            );
+            // get results from cache
+            const result = cache.getCache();
+            assert.equal(
+                result.asset ? Object.keys(result.asset).length : 0,
+                3,
+                'only 3 assets expected in cache'
+            );
+
+            assert.deepEqual(
+                await getActualJson('mcdev-issue-1157', 'asset', 'block'),
+                await testUtils.getExpectedJson('9999999', 'asset', 'block-1157-retrieve'),
+                'returned metadata was not equal expected'
+            );
+            expect(file(getActualFile('mcdev-issue-1157', 'asset', 'block', 'html'))).to.equal(
+                file(testUtils.getExpectedFile('9999999', 'asset', 'block-1157-retrieve', 'html'))
+            );
+
+            assert.equal(
+                testUtils.getAPIHistoryLength(),
+                30,
+                'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
+            );
+            return;
+        });
+    });
+});