Skip to Content
GraphQL Tools
DocumentationAPI@graphql-tools/utilssrcfunctionsisUrl

Function: isUrl()

isUrl(str): boolean

Defined in: packages/utils/src/helpers.ts:15

Checks if the given string is a valid URL.

Parameters

str

string

The string to validate as a URL

Returns

boolean

A boolean indicating whether the string is a valid URL

Remarks

This function first attempts to use the URL.canParse method if available. If not, it falls back to creating a new URL object to validate the string.