Mail relay: development hosts are known by pattern, with no env - built in: *.dev.netscale.pl
The launch rule called a site non-public only when IAPL_NOINDEX was set (or the project named its hosts).
The owner's development sites set nothing, so production's database copied onto a development address
counted as a launch and would have mailed real people.
- iapl({ developmentHosts }): host patterns of development addresses. Default DEFAULT_DEVELOPMENT_HOSTS =
['*.dev.netscale.pl'], Intecion's own development domain; a project replaces the list or empties it.
mail.relay.developmentHosts overrides it for the mail service.
- a site whose host matches is non-public exactly as with IAPL_NOINDEX=1; either signal is enough
- siteNonPublicSignal, matchDevelopmentHost, isDevelopmentHost, pluginDevelopmentHosts exported
- panel state: nonPublicBy, nonPublicPattern; doctor: mail-non-public (info) names the signal
- every case of the launch table runs with no env on the built-in pattern
- docs, AGENT.md, skills, changelog draft
Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5.2
parent
634908eb57
commit
14abf369da
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* Development addresses, known by pattern — no environment variable needed.
|
||||
*
|
||||
* A site whose own host matches one of these patterns is a development, preview or staging address: not the
|
||||
* public site. The plugin uses that for one decision today: such a site, when its database holds the mail-service
|
||||
* connection of ANOTHER host, is a copy of that site's data and does not mail real people by itself
|
||||
* (docs/email.md "Staging, copies and several hosts").
|
||||
*
|
||||
* Why a name is built in: `*.dev.netscale.pl` is Intecion's own development domain. Every site the team builds
|
||||
* starts there (`<name>.dev.netscale.pl`) and moves to its real domain at launch, and nothing in those sites'
|
||||
* environments marks them as development copies. With the pattern in the plugin they are protected without an
|
||||
* edit or an env step. It is a default like any other: `iapl({ developmentHosts: [...] })` replaces the list,
|
||||
* `[]` empties it, and another agency names its own pattern there.
|
||||
*/
|
||||
export const DEFAULT_DEVELOPMENT_HOSTS: readonly string[] = ['*.dev.netscale.pl']
|
||||
|
||||
/** Lowercase host of a URL or a bare host (`https://Acme.dev.example.pl/x` → `acme.dev.example.pl`); '' when unreadable. Keeps the port. */
|
||||
export function hostOf(value: null | string | undefined): string {
|
||||
const raw = (value ?? '').trim()
|
||||
if (!raw) {return ''}
|
||||
try {
|
||||
return new URL(/^[a-z][a-z0-9+.-]*:\/\//i.test(raw) ? raw : `https://${raw}`).host.toLowerCase()
|
||||
} catch {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The pattern that makes `host` a development address, or null. `*` stands for any characters (dots included);
|
||||
* a pattern without `*` must equal the host. The whole host must match; a port is not part of it.
|
||||
*/
|
||||
export function matchDevelopmentHost(host: null | string | undefined, patterns: readonly string[] = DEFAULT_DEVELOPMENT_HOSTS): null | string {
|
||||
const name = hostOf(host).replace(/:\d+$/, '')
|
||||
if (!name) {return null}
|
||||
for (const pattern of patterns) {
|
||||
const source = pattern.trim().toLowerCase().split('*').map((part) => part.replace(/[.+?^${}()|[\]\\]/g, '\\$&')).join('.*')
|
||||
if (source && new RegExp(`^${source}$`).test(name)) {return pattern}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/** Is `host` a development address (`matchDevelopmentHost` as a yes or no)? */
|
||||
export const isDevelopmentHost = (host: null | string | undefined, patterns: readonly string[] = DEFAULT_DEVELOPMENT_HOSTS): boolean =>
|
||||
matchDevelopmentHost(host, patterns) !== null
|
||||
Reference in New Issue
Block a user