mirror of
https://github.com/wassname/nvatom.git
synced 2026-09-12 12:40:53 +08:00
Fix a bug that utility.isNote does not handle symlinks properly
This commit is contained in:
+10
-1
@@ -11,7 +11,16 @@ class Utility
|
||||
@getPrimaryNoteExtension: -> if atom.config.get('nvatom.extensions').length then atom.config.get('nvatom.extensions')[0] else '.md'
|
||||
|
||||
@isNote: (filePath) ->
|
||||
return false unless path.extname(filePath) in atom.config.get('nvatom.extensions')
|
||||
|
||||
filePath = fs.normalize(filePath)
|
||||
return filePath.startsWith(Utility.getNoteDirectory()) and path.extname(filePath) in atom.config.get('nvatom.extensions')
|
||||
return true if filePath.startsWith(Utility.getNoteDirectory())
|
||||
return true if filePath.startsWith(fs.realpathSync(Utility.getNoteDirectory()))
|
||||
return false unless fs.existsSync(filePath)
|
||||
|
||||
filePath = fs.realpathSync(filePath)
|
||||
return true if filePath.startsWith(Utility.getNoteDirectory())
|
||||
return true if filePath.startsWith(fs.realpathSync(Utility.getNoteDirectory()))
|
||||
return false
|
||||
|
||||
@trim: (str) -> str?.replace /^\s+|\s+$/g, ''
|
||||
|
||||
Reference in New Issue
Block a user