> ## 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()

> Use this method to check a URL to see if it is malicious.

<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.
</Note>

## Example

<CodeGroup>
  ```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/warning?originUrl=https://www.mountaintop-finance.com"
  }
  ```

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

## Parameters

<ParamField body="url" type="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`
</ParamField>

## 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:

<ParamField body="result" type="object" required>
  <Expandable title="properties" defaultOpen>
    <ParamField body="ok" type="true" required>
      This property will be `true` if the check was successful.
    </ParamField>

    <ParamField body="url" type="string">
      The `url` property is the URL that was checked.
    </ParamField>

    <ParamField body="status" type="'ALLOWED' | 'BLOCKED' | 'UNKNOWN'" required>
      The `status` property indicates whether the URL is allowed or blocked.
    </ParamField>

    <ParamField body="redirectUrl" type="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 will return the ChainPatrol warning page URL,
      but you can override this by specifying your own `redirectUrl` in when
      instantiating the `ThreatDetector`.
    </ParamField>
  </Expandable>
</ParamField>

### Failure

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

<ParamField body="result" type="object" required>
  <Expandable title="properties" defaultOpen>
    <ParamField body="ok" type="false" required>
      This property will be `false` if the check was unsuccessful.
    </ParamField>

    <ParamField body="url" type="string">
      The `url` property is the URL that was checked.
    </ParamField>

    <ParamField body="error" type="string">
      The `error` property will contain a human-readable error message.
    </ParamField>
  </Expandable>
</ParamField>
