chore: stop ab test for image proxy
This commit is contained in:
+4
-10
@@ -3,7 +3,7 @@ import { fileURLToPath } from "node:url"
|
||||
|
||||
import { is } from "@electron-toolkit/utils"
|
||||
import { callWindowExpose } from "@follow/shared/bridge"
|
||||
import { imageRefererMatches } from "@follow/shared/image"
|
||||
import { IMAGE_PROXY_URL, imageRefererMatches } from "@follow/shared/image"
|
||||
import type { BrowserWindowConstructorOptions } from "electron"
|
||||
import { BrowserWindow, screen, shell } from "electron"
|
||||
|
||||
@@ -124,15 +124,9 @@ export function createWindow(
|
||||
}
|
||||
|
||||
window.webContents.session.webRequest.onBeforeSendHeaders((details, callback) => {
|
||||
const trueUrl =
|
||||
process.env["VITE_IMGPROXY_URL"] && details.url.startsWith(process.env["VITE_IMGPROXY_URL"])
|
||||
? decodeURIComponent(
|
||||
details.url.replace(
|
||||
new RegExp(`^${process.env["VITE_IMGPROXY_URL"]}/unsafe/\\d+x\\d+/`),
|
||||
"",
|
||||
),
|
||||
)
|
||||
: details.url
|
||||
const trueUrl = details.url.startsWith(IMAGE_PROXY_URL)
|
||||
? new URL(details.url).searchParams.get("url") || details.url
|
||||
: details.url
|
||||
const refererMatch = imageRefererMatches.find((item) => item.url.test(trueUrl))
|
||||
callback({
|
||||
requestHeaders: {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { imageRefererMatches, webpCloudPublicServicesMatches } from "@follow/shared/image"
|
||||
|
||||
import { getAbValue, isAbEnabled } from "~/hooks/biz/useAb"
|
||||
import {
|
||||
IMAGE_PROXY_URL,
|
||||
imageRefererMatches,
|
||||
webpCloudPublicServicesMatches,
|
||||
} from "@follow/shared/image"
|
||||
|
||||
export const getImageProxyUrl = ({
|
||||
url,
|
||||
@@ -11,12 +13,7 @@ export const getImageProxyUrl = ({
|
||||
width: number
|
||||
height: number
|
||||
}) => {
|
||||
const abValue = getAbValue("Image_Proxy_V2")
|
||||
if (isAbEnabled("Image_Proxy_V2")) {
|
||||
return `${abValue}?url=${encodeURIComponent(url)}&width=${width}&height=${height}`
|
||||
} else {
|
||||
return `${abValue}/unsafe/fit-in/${width}x${height}/${encodeURIComponent(url)}`
|
||||
}
|
||||
return `${IMAGE_PROXY_URL}?url=${encodeURIComponent(url)}&width=${width}&height=${height}`
|
||||
}
|
||||
|
||||
export const replaceImgUrlIfNeed = (url?: string) => {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
export const IMAGE_PROXY_URL = "https://webp.follow.is"
|
||||
|
||||
export const imageRefererMatches = [
|
||||
{
|
||||
url: /^https:\/\/\w+\.sinaimg.cn/,
|
||||
|
||||
Reference in New Issue
Block a user