Skip to content

Commit

Permalink
feat(preview panel): render nested references
Browse files Browse the repository at this point in the history
  • Loading branch information
Pakisan committed Sep 20, 2024
1 parent fe7a688 commit e7e965d
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import com.asyncapi.plugin.idea._core.AsyncAPISpecificationHtmlRenderer
import com.intellij.json.JsonFileType
import com.intellij.openapi.components.service
import com.intellij.openapi.vfs.LocalFileSystem
import com.intellij.util.io.getHostName
import com.intellij.util.io.isLocalHost
import com.intellij.util.io.origin
import io.netty.buffer.Unpooled
import io.netty.channel.ChannelHandlerContext
import io.netty.handler.codec.http.*
Expand All @@ -24,11 +27,18 @@ class StaticServer : HttpRequestHandler() {
private val asyncAPISpecificationHtmlRenderer = service<AsyncAPISpecificationHtmlRenderer>()

override fun isAccessible(request: HttpRequest): Boolean {
// TODO: research why netty recognize origin: null as "null" instead of null
if (request.origin.equals("null") && urlProvider.isPlugin(request)) {
val hostName = getHostName(request)
// return hostName != null && isOriginAllowed(request) != OriginCheckResult.FORBID && isLocalHost(hostName)
return hostName != null && isLocalHost(hostName)
}

return urlProvider.isPlugin(request) && super.isAccessible(request)
}

override fun isSupported(request: FullHttpRequest): Boolean {
return urlProvider.isPlugin(request) && super.isAccessible(request)
return urlProvider.isPlugin(request) && super.isSupported(request)
}

override fun process(
Expand Down

0 comments on commit e7e965d

Please sign in to comment.