<commit_before>package com.softmotions.ncms.mtt.http

import com.google.inject.Inject
import com.google.inject.Singleton
import com.softmotions.ncms.asm.CachedPage
import com.softmotions.ncms.asm.PageService
import org.slf4j.LoggerFactory
import javax.annotation.concurrent.ThreadSafe
import javax.servlet.http.HttpServletRequest

/**
 * Request page filter.
 *
 * @author <NAME> (<EMAIL>)
 */
@Singleton
@ThreadSafe
open class MttPageFilter
@Inject
constructor(private val ps: PageService) : MttFilterHandler {

    companion object {
        val log = LoggerFactory.getLogger(MttPageFilter::class.java)
    }

    override val type: String = "page"

    private val GUID_REGEXP: Regex = Regex("[0-9a-f]{32}")

    override fun matched(ctx: MttFilterHandlerContext, req: HttpServletRequest): Boolean {
        val spec = ctx.spec
        var pageName = GUID_REGEXP.find(spec.path("pageref").asText(null))?.value ?: return false

        var uri = req.requestURI<commit_msg>#347 PageFilter simplify<commit_after>package com.softmotions.ncms.mtt.http

import com.google.inject.Inject
import com.google.inject.Singleton
import com.softmotions.ncms.asm.CachedPage
import com.softmotions.ncms.asm.PageService
import org.slf4j.LoggerFactory
import javax.annotation.concurrent.ThreadSafe
import javax.servlet.http.HttpServletRequest

/**
 * Request page filter.
 *
 * @author <NAME> (<EMAIL>)
 */
@Singleton
@ThreadSafe
open class MttPageFilter
@Inject
constructor(private val ps: PageService) : MttFilterHandler {

    companion object {
        val log = LoggerFactory.getLogger(MttPageFilter::class.java)
    }

    override val type: String = "page"

    private val PAGEREF_REGEXP = Regex("page:\\s*([0-9a-f]{32})(\\s*\\|.*)?", RegexOption.IGNORE_CASE)

    override fun matched(ctx: MttFilterHandlerContext, req: HttpServletRequest): Boolean {
        val spec = ctx.spec
        val mres = PAGEREF_REGEXP.matchEntire(spec.path("pageref").asText(null)) ?: return false
        val pageName = mres.groupValues[1]

        var uri = req.requestURI
{'fraction_non_alphanumeric': 0.11295843520782396, 'fraction_numerical': 0.006845965770171149, 'mean_word_length': 4.232736572890025, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2774502', 'n_tokens_mistral': 659, 'n_tokens_neox': 647, 'n_words': 136}