module Analyzer::Erlang::Helper

Overview

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

Extended Modules

Defined in:

analyzer/analyzers/erlang/erlang_helper.cr

Instance Method Summary

Instance Method Detail

def 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.


[View source]
def 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.

[View source]