def named.of

ezx@1.11.0.0 · src/pkg/pkg.bend:411

import ezx@1.11.0.0/src/pkg/pkg.bend as Pkg
import Base
import ezx@1.11.0.0/src/pkg/path.bend as P

411# the `<name>@<version>` an import names, or "" when it names none: the first
412# component of its normalised path, when that holds an `@` and a `/` follows
413# it, as bend's loader reads it
414def named.of(+spec: String) -> String:
415  +n = P.norm(spec)
416  +first = word(String.split(n, '/'), 0n)
417  named.pick(Bool.and(String.contains(n, "/"), String.contains(first, "@")), first)

Uses (8)

Used by (3)