Dark theme | Light theme

February 8, 2022

DataWeave Delight: Parsing a URL to a URI object

We can turn a URL string value into an object with fields that contain information about the URL using the parseURI function. This function is part of the code dw::core::URL module. The returned object is of type URI and has fields like host, path, query, scheme and more.

In the following example we use the parseURI function on the URL and in the output we can see the different fields:


%dw 2.0

import parseURI from dw::core::URL

var blogURI = parseURI("")

output application/json
// URI object has fields with information about the parsed URL.


  "isValid": true,
  "raw": "",
  "host": "",
  "authority": "",
  "path": "/search",
  "query": "q=DataWeave",
  "scheme": "https",
  "isAbsolute": true,
  "isOpaque": false

Written with DavaWeave 2.4.