mirror of https://github.com/Ashinch/ReadYou.git
feat(ui): add referer header with domain extraction for image proxying (#795)
This commit is contained in:
parent
fe62743356
commit
e795daedc8
|
@ -11,15 +11,13 @@ import androidx.compose.ui.graphics.drawscope.DrawScope
|
|||
import androidx.compose.ui.graphics.painter.Painter
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import coil.compose.rememberAsyncImagePainter
|
||||
import coil.compose.rememberImagePainter
|
||||
import coil.request.ImageRequest
|
||||
import coil.size.Precision
|
||||
import coil.size.Scale
|
||||
import coil.size.Size
|
||||
import me.ash.reader.R
|
||||
import me.ash.reader.ui.ext.extractDomain
|
||||
|
||||
val SIZE_1000 = Size(1000, 1000)
|
||||
|
||||
|
@ -37,7 +35,9 @@ fun RYAsyncImage(
|
|||
) {
|
||||
Image(
|
||||
painter = rememberAsyncImagePainter(
|
||||
ImageRequest.Builder(LocalContext.current).data(data = data).apply {
|
||||
ImageRequest.Builder(LocalContext.current).addHeader(
|
||||
"Referer", (data as String).extractDomain() ?: ""
|
||||
).data(data = data).apply {
|
||||
if (placeholder != null) placeholder(placeholder)
|
||||
if (error != null) error(error)
|
||||
crossfade(true)
|
||||
|
@ -141,4 +141,4 @@ private val DefaultOnDraw: DrawScope.(ForwardingDrawInfo) -> Unit = { info ->
|
|||
info.colorFilter
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue