Sanitizing HTTP Requests

Hi all,
Pardon if I don’t use the right jargon, but using a specific API and I get the following type of results:

"https%3A%2F%2Fbooot.nl%2Fluxury-cruise%2F"

Is there a way to “sanitize” these results without I assume using a replace function? Thank you very much in advance.

Yes, you can do that with a function node. Check the example below:

{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "items[0].json.url = \"https%3A%2F%2Fbooot.nl%2Fluxury-cruise%2F\";\nreturn items;"
      },
      "name": "Function",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        480,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "item.url = decodeURIComponent(item.url)\nreturn item"
      },
      "name": "FunctionItem",
      "type": "n8n-nodes-base.functionItem",
      "typeVersion": 1,
      "position": [
        710,
        300
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Function",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Function": {
      "main": [
        [
          {
            "node": "FunctionItem",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
1 Like

That was Fast & Furious :slight_smile:. Thanks a 100, will test right now :slight_smile:

haha I just happened to be here :wink:

It works great “flat” JSON, but like this I am not able to perform same, has a different structure. Thanks :slight_smile:

[

{

“site”: {

“https%3A%2F%2Fbooot.nl%2Fluxury-cruise%2F”: {

“type”: “e”,

“id”: “Jpa”

},

Alright, I solved it using a couple more functions and Split a variable!.

:slight_smile:

1 Like