---
schema_version: "1"
id: 26ef36d7c119c40cb21aca05647f3febf1701dd42e03a11a6175c474bd836ef8
title: compose
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.3/dw-url-functions-compose.md
canonical_url: https://docs.mulesoft.com/dataweave/2.3/dw-url-functions-compose
source_site: docs.mulesoft.com
content_type: documentation
content_hash: bbea096d0494804721bf63e03bc0ce18240f3dca815c1b84f45bb02c1f403d9d
description: MuleSoft Documentation Site
release: "2.3"
latest: false
---
---
product: DataWeave
version: 2.3
---

# compose

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

## compose(Array<String>, Array<String>): String

Uses a custom string interpolator to replace URL components with a `encodeURIComponent` result. You
can call this function using the standard call, or a simplified version.

### Parameters

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>baseStringArray</code></p></td><td><p>A string array that contains the URL parts to interpolate using the strings in the <code>interpolationStringArray</code> parameter.</p></td></tr><tr><td><p><code>interpolationStringArray</code></p></td><td><p>A string array that contains the strings used to interpolate the <code>baseStringArray</code>.</p></td></tr></tbody></table>

### Example

The following example uses the compose function to form an encoded URL, the first parameter is an
array of two strings that are part of the URL and the second parameter is the `urlPath` variable
that is used to interpolate the strings in the first parameter. Notice that the spaces in the input
are encoded in the output URL as `%20`.

#### Source

```DataWeave
%dw 2.0
output application/json
var urlPath = "content folder"
import * from dw::core::URL
---
{ "encodedURL" : compose(["http://examplewebsite.com/", "/page.html"], ["$(urlPath)"]) }
```

#### Output

```JSON
{ "encodedURL" : "http://examplewebsite.com/content%20folder/page.html" }
```

## Simplified Syntax

You can also call this function using the simplified syntax, which uses backticks (`` ` ``) to
enclose the string that includes the variable to encode.

### Example

This example shows how to use the simplified syntax to obtain the same result as in the previous
example.

#### Source

```DataWeave
%dw 2.0
output application/json
var urlPath = "content folder"
import * from dw::core::URL
---
{ "encodedURL" : compose `http://examplewebsite.com/$(urlPath)/page.html` }
```

#### Output

```JSON
{ "encodedURL" : "http://examplewebsite.com/content%20folder/page.html" }
```
