about summary refs log tree commit diff
path: root/tvix/nix-compat/src/store_path/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/nix-compat/src/store_path/mod.rs')
-rw-r--r--tvix/nix-compat/src/store_path/mod.rs16
1 files changed, 10 insertions, 6 deletions
diff --git a/tvix/nix-compat/src/store_path/mod.rs b/tvix/nix-compat/src/store_path/mod.rs
index e9e2978b7cc8..b68a4f317189 100644
--- a/tvix/nix-compat/src/store_path/mod.rs
+++ b/tvix/nix-compat/src/store_path/mod.rs
@@ -153,7 +153,7 @@ impl StorePath {
     }
 }
 
-/// Checks a given &[u8] to match the restrictions for store path names, and
+/// Checks a given &[u8] to match the restrictions for [StorePath::name], and
 /// returns the name as string if successful.
 pub(crate) fn validate_name(s: &[u8]) -> Result<String, Error> {
     // Empty names are not allowed.
@@ -161,11 +161,6 @@ pub(crate) fn validate_name(s: &[u8]) -> Result<String, Error> {
         return Err(Error::InvalidLength());
     }
 
-    // First character cannot be a period
-    if s[0] == b'.' {
-        return Err(Error::InvalidName(s.to_vec(), 0));
-    }
-
     for (i, c) in s.iter().enumerate() {
         if c.is_ascii_alphanumeric()
             || *c == b'-'
@@ -226,6 +221,15 @@ mod tests {
         assert_eq!(example_nix_path_str, nixpath.to_string())
     }
 
+    /// This is the store path produced after `nix-store --add`'ing an
+    /// empty `.gitignore` file.
+    #[test]
+    fn starts_with_dot() {
+        let nix_path_str = "fli4bwscgna7lpm7v5xgnjxrxh0yc7ra-.gitignore";
+        let nixpath = StorePath::from_bytes(nix_path_str.as_bytes()).expect("must succeed");
+        assert_eq!(".gitignore", nixpath.name);
+    }
+
     #[test]
     fn invalid_hash_length() {
         StorePath::from_bytes(b"00bgd045z0d4icpbc2yy-net-tools-1.60_p20170221182432")