> ## Documentation Index
> Fetch the complete documentation index at: https://chainpatrol.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# url()

> Check whether a URL is a phishing or scam site with ThreatDetector.url(), returning an ALLOWED, BLOCKED, UNKNOWN or IGNORED status plus an optional redirectUrl.

> [!NOTE]
>
> Only the domain portion of the URL is checked. The path and query string are
> stripped before sending the request to the ChainPatrol API to preserve privacy
> and prevent leaking sensitive information.

## Example

```js Code theme={null}
const result = await detector.url("https://www.mountaintop-finance.com");

console.log(result);
```

```js Output (Allowed) theme={null}
{
    ok: true,
    url: "mountaintop-finance.com",
    status: "ALLOWED",
}
```

```js Output (Blocked) theme={null}
{
    ok: true,
    url: "mountaintop-finance.com",
    status: "BLOCKED",
    redirectUrl: "https://app.chainpatrol.io/preview?target=https%3A%2F%2Fwww.mountaintop-finance.com&originUrl=https%3A%2F%2Fwww.mountaintop-finance.com"
}
```

```js Output (Ignored) theme={null}
{
    ok: true,
    url: "https://www.mountaintop-finance.com",
    status: "IGNORED",
}
```

```js Output (Error) theme={null}
{
    ok: false,
    url: "abcdefgh",
    error: "Unable to parse domain"
}
```

## Parameters

**url** `string` *required*

The URL to check. This can be a full URL or a domain. The URL will be
parsed to extract only the domain for checking.

Ex. `https://google.com` or `google.com`

## Return Value

The return value is a promise that resolves with an object containing the
result of the check.

### Success

If the check was successful, the object will contain the following properties:

**result** `object` *required*

**properties**

**ok** `true` *required*

This property will be `true` if the check was successful.

**url** `string`

The `url` property is the URL that was checked.

**status** `'ALLOWED' | 'BLOCKED' | 'UNKNOWN' | 'IGNORED'` *required*

The `status` property indicates whether the URL is allowed or blocked.
It is `IGNORED` when the domain was added with
[`ignore()`](https://chainpatrol.com/docs/sdk/threat-detector/instance-methods/ignore), for example
after a user chose to continue at their own risk.

**redirectUrl** `string`

The `redirectUrl` property specifies where to redirect the user when the
detector detects a threat. This property will only be present if the
`status` property is set to `BLOCKED`.

By default, the detector returns the ChainPatrol warning page,
`https://app.chainpatrol.io/preview`, with the checked URL in the `target`
and `originUrl` query parameters. You can override this by passing your
own `redirectUrl` when creating the `ThreatDetector`.

### Failure

However, if the check was unsuccessful, the object will contain the following:

**result** `object` *required*

**properties**

**ok** `false` *required*

This property will be `false` if the check was unsuccessful.

**url** `string`

The `url` property is the URL that was checked.

**error** `string`

The `error` property will contain a human-readable error message.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.