Skip to content

Home > robinson > isUrl

isUrl() function

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

检查是否为有效的URL

Signature:

typescript
declare function isUrl(url: string): boolean;
declare function isUrl(url: string): boolean;

Parameters

ParameterTypeDescription
urlstringURL字符串

Returns:

boolean

{boolean} - 一个布尔值。

Example

JavaScript
 let url = 'https://example.com'; isUrl(url) // true
 let url = 'invalid-url'; isUrl(url) // false
 let url = 'https://example.com'; isUrl(url) // true
 let url = 'invalid-url'; isUrl(url) // false

Released under the MIT License.