Split / Parcel Data from webbook

Split / Parcel Data from webbook

I have data: url = https://www.domain.com

and the data I want is simply: domain.com

I have been trying to do with the HTML Extract & the Function node.
any insight would be greatly appreciated.

Been trying to get this done for over an hour and I feel like it should be pretty simple :slight_smile:

Hi @David_Go, this should indeed be simple. You could use an expression that replaces the https://www. with an empty string like this:

image

Example Workflow
{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        240,
        300
      ]
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "url",
              "value": "https://www.domain.com"
            }
          ]
        },
        "options": {}
      },
      "name": "Set Example Data",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        460,
        300
      ]
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "result",
              "value": "={{$json[\"url\"].replace(\"https://www.\", \"\")}}"
            }
          ]
        },
        "options": {}
      },
      "name": "Replace Example",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        680,
        300
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Set Example Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Example Data": {
      "main": [
        [
          {
            "node": "Replace Example",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

This example workflow uses the replace() method through an expression. You could append more .replace() as needed or try regular expressions to cover more cases (like http://www. or any other prefix you might encoutner).

1 Like

AMAZING - You just make my n8n install so much more powerful with this :slight_smile:

1 Like

Awesome, I am happy to hear this was helpful! You might also want to leave your vote on this feature request from @RedPacketSec to save users from having to write JavaScript for such manipulations:

1 Like

Done made my vote :slight_smile:

1 Like