npm.io
1.5.280 • Published 8 months ago

@sequencemedia/verify-url

Licence
ISC
Version
1.5.280
Deps
4
Size
37 kB
Vulns
0
Weekly
0

@sequencemedia/verify-url

Verifies that a URL is publicly accessible on the network

verifyUrl

The verifyUrl function returns a Promise which resolves to an object

That object is a description

  • It always contains a verification string (either PASS or FAIL)
  • It always contains the url string

1 - The verification request was successful and the remote host returned a status in the success range

The value of verification in the description is PASS

  export interface ResponseSuccess {
    verification: string;
    url: string;
  }
2 - The verification request was successful but the remote host returned a status in the failure range

Dispatching a request was fine but the host or the path was not

  • Perhaps a 500
  • Perhaps a 404
  • Etc

The value of verification in the description is FAIL

  export interface ResponseFailure {
    verification: string;
    url: string;
    response: {status: number};
  }
3 - The verification request failed

Either the url was not a valid URL or dispatching a request to it generated an error

  • Perhaps the host does not exist
  • Perhaps the host is not reachable
  • Etc

The value of verification in the description is FAIL

  export interface RequestFailure {
    verification: string;
    url: string;
    error: {code: string};
  }

Keywords