summaryrefslogtreecommitdiffstats
path: root/lib/utils
diff options
context:
space:
mode:
authorJohan Preynat <johan.preynat@gmail.com>2016-04-29 14:35:56 +0200
committerJohan Preynat <johan.preynat@gmail.com>2016-04-29 14:38:12 +0200
commit94199af7b293b9c6f82a2e1c341587adee5b0792 (patch)
tree44de86b051017c509c35320e127fd95e99ceefef /lib/utils
parentb8d7a00f58401d827ef06b76f4a9f189b89c7606 (diff)
downloadgitbook-94199af7b293b9c6f82a2e1c341587adee5b0792.zip
gitbook-94199af7b293b9c6f82a2e1c341587adee5b0792.tar.gz
gitbook-94199af7b293b9c6f82a2e1c341587adee5b0792.tar.bz2
Add location.areIdenticalPaths(p1,p2) to effectively compare two paths
Diffstat (limited to 'lib/utils')
-rw-r--r--lib/utils/location.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/utils/location.js b/lib/utils/location.js
index 94d9b2a..84a71ad 100644
--- a/lib/utils/location.js
+++ b/lib/utils/location.js
@@ -83,7 +83,20 @@ function relativeForFile(baseFile, file) {
return relative(path.dirname(baseFile), file);
}
+/**
+ Compare two paths, return true if they are identical
+ ('README.md', './README.md') -> true
+
+ @param {String} p1: first path
+ @param {String} p2: second path
+ @return {Boolean}
+*/
+function areIdenticalPaths(p1, p2) {
+ return normalize(p1) === normalize(p2);
+}
+
module.exports = {
+ areIdenticalPaths: areIdenticalPaths,
isExternal: isExternal,
isRelative: isRelative,
isAnchor: isAnchor,