Commit 871a6e45 authored by Robert Hensing's avatar Robert Hensing Committed by github-actions[bot]
Browse files

testers.lycheeLinkCheck: Validate regex...

... because of the odd choice of config syntax.

(cherry picked from commit 89092532e7992954abf05d25ea0578efa65889f7)
parent 5a51f54e
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
deps@{ formats, lib, lychee, stdenv, writeShellApplication }:
let
  inherit (lib) isPath mapAttrsToList;
  inherit (lib.strings) hasPrefix;
  inherit (lib) mapAttrsToList throwIf;
  inherit (lib.strings) hasInfix hasPrefix escapeNixString;

  toURL = v:
    let s = "${v}";
@@ -10,6 +10,11 @@ let
      "file://${s}"
    else s;

  withCheckedName = name:
    throwIf
      (hasInfix " " name)
      "lycheeLinkCheck: remap patterns must not contain spaces. A space marks the end of the regex in lychee.toml. Please change attribute name remap.${escapeNixString name}";

  # See https://nixos.org/manual/nixpkgs/unstable/#tester-lycheeLinkCheck
  # or doc/builders/testers.chapter.md
  lycheeLinkCheck = {
@@ -30,7 +35,10 @@ let
        config = {
          include_fragments = true;
        } // lib.optionalAttrs (finalAttrs.passthru.remap != { }) {
          remap = mapAttrsToList (name: value: "${name} ${toURL value}") finalAttrs.passthru.remap;
          remap =
            mapAttrsToList
              (name: value: withCheckedName name "${name} ${toURL value}")
              finalAttrs.passthru.remap;
        } // extraConfig;
        online = writeShellApplication {
          name = "run-lychee-online";