 # Score adjustment for path
 #
 
-pathScore = (subject, subject_lw, prepQuery, fullPathScore) ->
+scorePath = (subject, subject_lw, prepQuery, fullPathScore) ->
   return 0 if fullPathScore is 0
-
 
   # Skip trailing slashes
   end = subject.length - 1
-  end-- while subject[end] is PathSeparator
+  while subject[end] is PathSeparator then end--
 
   # Get position of basePath of subject.
   basePos = subject.lastIndexOf(PathSeparator, end)

  depth = prepQuery.depth

  # Get that many folder from subject
  while(depth-- > 0)
    basePos = subject.lastIndexOf(PathSeparator, basePos - 1)
    if (basePos is -1) then return fullPathScore #consumed whole subject ?

  # Get basePath score
  basePos++
  end++
  basePathScore = doScore(subject[basePos...end], subject_lw[basePos...end], prepQuery)
  basePathScore *= extAdjust

  # Final score is linear interpolation between base score and full path score.
  # For low directory depth, interpolation favor base Path then include more of full path as depth increase

# Main scoring algorithm
#

scoreMain = (subject, subject_lw, prepQuery) ->
  query = prepQuery.query
  query_lw = prepQuery.query_lw

