diff options
| author | tv <tv@krebsco.de> | 2026-09-30 05:02:08 +0200 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-09-30 05:08:54 +0200 |
| commit | f460d30844358ef65477457a106681dc420e6452 (patch) | |
| tree | 2a15607d18c84e48fc964824d828017b142d2541 /src/MdBlocks/Address.hs | |
| parent | 80efc38f395b9ee70545d586ef02c68cf952be8d (diff) | |
drop support for traversing directories
Diffstat (limited to 'src/MdBlocks/Address.hs')
| -rw-r--r-- | src/MdBlocks/Address.hs | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/MdBlocks/Address.hs b/src/MdBlocks/Address.hs index 8a32e0f..25ef26f 100644 --- a/src/MdBlocks/Address.hs +++ b/src/MdBlocks/Address.hs @@ -12,9 +12,10 @@ import qualified Data.Text as T import MdBlocks.Types -data Address - = GlobalId Text - | FileAddress FilePath Text +data Address = Address + { addressFile :: FilePath + , addressId :: Text + } deriving (Show, Eq) parseAddress :: String -> Either String Address @@ -22,22 +23,23 @@ parseAddress input = case T.breakOn "#" (T.pack input) of (file, ident) | T.null file -> - Left "address must contain a file path" + Left "address must contain a file path before '#'" | T.null ident -> Left "address must contain a block id after '#'" | otherwise -> Right - (FileAddress - (T.unpack file) - (T.drop 1 ident)) + Address + { addressFile = T.unpack file + , addressId = T.drop 1 ident + } addressOf :: Block -> Text addressOf b = case mdId (blockMeta b) of - Just x -> - T.pack (blockFile b) <> "#" <> x + Just ident -> + T.pack (blockFile b) <> "#" <> ident Nothing -> T.pack (blockFile b) |
