Skip to content

Add Configuration option to filter requests? #112

@scottnicolson

Description

@scottnicolson

I have monkey patched the interceptable_request? method in the Hotwire::Spark::Middleware to filter out certain paths. I user lookbook to preview viewcomponents, Lookbook adds some chrome to navigate component previews and the component preview is iframed inside the chrome. I didn't want spark to inject itself in the outer page so I added a extension module as shown below. It is a bit hacky, and wondered whether I should create a PR to add a configuration option to allow filtering of URLs? If you think this is worthy please let me know and I ca n put together a PR.

  module HotwireSparkExtensions
    private

    def interceptable_request?
      super && !@request.fullpath.start_with?('/component-previews/inspect')
    end
  end

  class Hotwire::Spark::Middleware
    prepend HotwireSparkExtensions
  end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions