function couldBeAPage
couldBeAPage(url: string): boolean

Whether a URL could name a page at all: .html, or no extension.

Cheap and syntactic, so the fetch below is only spent where the answer could be yes — a -test.js is a module whatever it is served with, and asking a server twice about one is the kind of waste that only shows up as a slow suite.

import { couldBeAPage } from './remote-page.ts';

couldBeAPage('https://x/test/'); // true
couldBeAPage('https://x/test'); // true
couldBeAPage('https://x/tests/index.html'); // true
couldBeAPage('https://x/tests/cart-test.js'); // false — that is a module

Parameters

url: string

Return Type

boolean

Usage

import { couldBeAPage } from "lib/setup/remote-page.ts";