Module: StyleCapsule::AssetPath

Defined in:
lib/style_capsule/asset_path.rb,
sig/style_capsule.rbs

Overview

Validates logical asset paths for stylesheet registration (blocks injection / absurd paths).

Constant Summary collapse

MAX_PATH_LENGTH =
1024

Class Method Summary collapse

Class Method Details

.validate_logical_path!(path) ⇒ String

Returns Stripped path.

Parameters:

  • path (String)

    Logical path (e.g. "stylesheets/admin/foo" or "builds/capsules/my_component")

Returns:

  • (String)

    Stripped path

Raises:

  • (ArgumentError)

    If path is invalid



11
12
13
14
15
16
17
18
19
20
# File 'lib/style_capsule/asset_path.rb', line 11

def self.validate_logical_path!(path)
  unless path.is_a?(String)
    raise ArgumentError, "stylesheet path must be a String (got #{path.class})"
  end

  s = path.strip
  validate_non_empty_path!(s)
  validate_path_segments!(s, path)
  s
end