Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 1x 1x 1x 1x 1x 1x 1x 1x 1x | import {
explorerUrlMigrationsById,
migrateExplorerUrl,
} from "../explorer/urlMigrations/ExplorerUrlMigrations"
import { getExplorerRedirectForPath } from "../explorerAdminServer/ExplorerRedirects"
import { Url } from "../clientUtils/urls/Url"
export const replaceIframesWithExplorerRedirectsInWordPressPost = (
cheerio: CheerioStatic
) =>
cheerio("iframe")
.toArray()
.forEach((el) => {
let url = Url.fromURL(el.attribs["src"].trim())
if (!url.pathname) return
const explorerRedirect = getExplorerRedirectForPath(url.pathname)
if (explorerRedirect) {
const { migrationId, baseQueryStr } = explorerRedirect
const { migrateUrl } = explorerUrlMigrationsById[migrationId]
url = migrateUrl(url, baseQueryStr)
}
url = migrateExplorerUrl(url)
el.attribs["src"] = url.fullUrl
})
|