Do not add the mount to a site URL that already has it
a381174 fixed a link missing its subpath and produced one carrying it twice:
https://<host>/shopdb/shopdb/s/<token>.
site_base_url is DOCUMENTED as scheme + host, and sites really do set the full
base including the subpath. Trusting the description rather than tolerating what
is configured is the same mistake as the last one, pointed the other way.
The mount is now appended only when the configured URL does not already end with
it, which covers every combination a site can have: base with the subpath, base
without it, a trailing slash on either, and a site mounted at the root where
there is no subpath at all.
Checked all five by evaluating the expression rather than reasoning about it.
This commit is contained in:
@@ -151,12 +151,19 @@ async function createLink() {
|
||||
// withBase for the path: a site served under /shopdb or /ops carries that
|
||||
// in front of every route, and leaving it off produced a 404 from IIS for a
|
||||
// secret that existed - with the sender shown a link that could never work.
|
||||
const origin = (await getSiteBaseUrl()).replace(/\/+$/, '')
|
||||
const path = withBase(`/s/${token}`)
|
||||
// site_base_url is DOCUMENTED as scheme + host, but sites really do set the
|
||||
// full base including the subpath - and appending the mount to one that
|
||||
// already carries it produced /shopdb/shopdb/s/<token>. Tolerate both
|
||||
// rather than trusting the description: add the mount only when it is not
|
||||
// there already.
|
||||
const configured = (await getSiteBaseUrl()).replace(/\/+$/, '')
|
||||
const mount = withBase('/').replace(/\/+$/, '')
|
||||
const needsMount = mount && !configured.endsWith(mount)
|
||||
|
||||
// The key rides in the FRAGMENT. Browsers never send it, so it reaches the
|
||||
// recipient and nowhere else.
|
||||
link.value = `${origin}${path}#${sealed.fragmentKey}`
|
||||
link.value =
|
||||
`${configured}${needsMount ? mount : ''}/s/${token}#${sealed.fragmentKey}`
|
||||
// Drop the plaintext as soon as it is sealed: no reason to keep it in memory
|
||||
// behind the link that replaced it.
|
||||
plaintext.value = ''
|
||||
|
||||
Reference in New Issue
Block a user