module

Analyzer::Erlang::Helper

Shared helpers for the Erlang framework analyzers (Cowboy, Elli).

Instance methods

parse_cowboy_path(path_match : String) : Tuple(String, Array(Param))

Erlang path matches appear both as plain strings ("/users/:id") and as binaries (<<"/users/:id">>). Both carry the same syntax.

Segment forms, per cowboy_router:

  • :name — a binding, i.e. a path parameter.
  • [...] — matches all remaining segments (wildcard).
  • [/optional]— an optional segment.
  • :name[...] — a binding that also swallows the remainder.

Returns the noir-normalized URL plus the bindings as path params.

Source
strip_erlang_comments(text : String) : String

Blank out % line comments while PRESERVING newlines/offsets, so a comment never collapses lines and shifts every later endpoint's reported line number.

Erlang has three constructs a naive %-to-end-of-line scan gets wrong, and all three appear in real dispatch tables:

  • "..." strings — "100%" is not a comment.
  • '...' quoted atoms — 'GET%', and more commonly '_'.
  • $c character literals — $% IS the percent character, and $'/$" are quote characters that must not open a string.
Source