aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-06-10 00:40:58 +1200
committerTom Ryder <tom@sanctum.geek.nz>2018-06-10 00:40:58 +1200
commit095a09fe160e9b342c817a5a2df075f9256242cd (patch)
tree81909210911a8869bc3d8e2e1a8d0e2b765410aa
parente92517df50a7450ec51f2dbb872f89034e90e6d4 (diff)
downloadvim-redact-pass-095a09fe160e9b342c817a5a2df075f9256242cd.tar.gz
vim-redact-pass-095a09fe160e9b342c817a5a2df075f9256242cd.zip
Flesh out paths fully before comparisonsv1.1.0
-rw-r--r--VERSION2
-rw-r--r--plugin/redact_pass.vim20
2 files changed, 18 insertions, 4 deletions
diff --git a/VERSION b/VERSION
index 3eefcb9..9084fa2 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.0.0
+1.1.0
diff --git a/plugin/redact_pass.vim b/plugin/redact_pass.vim
index 66916a7..14919bb 100644
--- a/plugin/redact_pass.vim
+++ b/plugin/redact_pass.vim
@@ -24,9 +24,23 @@ let s:pattern = '\m\C/pass\.[^/]\+/[^/]\+\.txt$'
" file in the argument list is within the named dir, and that the whole path
" matches the above pattern immediately after that dir name
function! s:PassPath(root)
- return strlen(a:root)
- \ && stridx(argv(0), a:root) == 0
- \ && strlen(a:root) == match(argv(0), s:pattern)
+
+ " Check we actually got a value, i.e. this wasn't an empty environment
+ " variable
+ if !strlen(a:root)
+ return 0
+ endif
+
+ " Full resolved path to the root dir with no trailing slashes
+ let l:root = fnamemodify(a:root, ':p:h')
+
+ " Full resolved path to the first file in the arg list
+ let l:path = fnamemodify(argv(0), ':p')
+
+ " Check the string all match and at the expected points
+ return stridx(l:path, l:root) == 0
+ \ && strlen(l:root) == match(l:path, s:pattern)
+
endfunction
" Check whether we should set redacting options or not