forked from mirrors/nixpkgs
Merge pull request #204087 from ncfavier/splitString-simplify
This commit is contained in:
commit
22af649d14
|
@ -510,7 +510,7 @@ rec {
|
|||
toUpper = replaceChars lowerChars upperChars;
|
||||
|
||||
/* Appends string context from another string. This is an implementation
|
||||
detail of Nix.
|
||||
detail of Nix and should be used carefully.
|
||||
|
||||
Strings in Nix carry an invisible `context` which is a list of strings
|
||||
representing store paths. If the string is later used in a derivation
|
||||
|
@ -533,13 +533,11 @@ rec {
|
|||
splitString "/" "/usr/local/bin"
|
||||
=> [ "" "usr" "local" "bin" ]
|
||||
*/
|
||||
splitString = _sep: _s:
|
||||
splitString = sep: s:
|
||||
let
|
||||
sep = builtins.unsafeDiscardStringContext _sep;
|
||||
s = builtins.unsafeDiscardStringContext _s;
|
||||
splits = builtins.filter builtins.isString (builtins.split (escapeRegex sep) s);
|
||||
splits = builtins.filter builtins.isString (builtins.split (escapeRegex (toString sep)) (toString s));
|
||||
in
|
||||
map (v: addContextFrom _sep (addContextFrom _s v)) splits;
|
||||
map (addContextFrom s) splits;
|
||||
|
||||
/* Return a string without the specified prefix, if the prefix matches.
|
||||
|
||||
|
|
Loading…
Reference in a new issue