Fix Project::relativePath w/ URLs

This commit is contained in:
Max Brunsfeld 2015-03-13 15:07:44 -07:00
parent 28d617e799
commit 587ebd7538
2 changed files with 5 additions and 1 deletions

View File

@ -486,6 +486,11 @@ describe "Project", ->
randomPath = path.join("some", "random", "path")
expect(atom.project.relativizePath(randomPath)).toEqual [null, randomPath]
describe "when the given path is a URL", ->
it "returns null for the root path, and the given path unchanged", ->
url = "http://the-path"
expect(atom.project.relativizePath(url)).toEqual [null, url]
describe ".contains(path)", ->
it "returns whether or not the given path is in one of the root directories", ->
rootPath = atom.project.getPaths()[0]

View File

@ -288,7 +288,6 @@ class Project extends Model
# * `relativePath` {String} The relative path from the project directory to
# the given path.
relativizePath: (fullPath) ->
return fullPath if fullPath?.match(/[A-Za-z0-9+-.]+:\/\//) # leave path alone if it has a scheme
for rootDirectory in @rootDirectories
relativePath = rootDirectory.relativize(fullPath)
return [rootDirectory.getPath(), relativePath] unless relativePath is fullPath