Don't resolve uris when project has not path

This commit is contained in:
Kevin Sawicki
2014-06-02 15:39:43 -07:00
parent b4871fddfb
commit 94f86cb461
2 changed files with 10 additions and 2 deletions

View File

@@ -156,10 +156,18 @@ describe "Project", ->
expect(atom.project.resolve('a')).toBe absolutePath
expect(atom.project.resolve(absolutePath + '/../a')).toBe absolutePath
expect(atom.project.resolve('a/../a')).toBe absolutePath
expect(atom.project.resolve()).toBeUndefined()
describe "when passed a uri with a scheme", ->
it "does not modify uris that begin with a scheme", ->
expect(atom.project.resolve('http://zombo.com')).toBe 'http://zombo.com'
atom.project.setPath()
expect(atom.project.resolve('http://github.com')).toBe 'http://github.com'
describe "when the project has no path", ->
it "returns undefined", ->
atom.project.setPath()
expect(atom.project.resolve('test.txt')).toBeUndefined()
describe ".setPath(path)", ->
describe "when path is a file", ->

View File

@@ -98,8 +98,8 @@ class Project extends Model
if uri?.match(/[A-Za-z0-9+-.]+:\/\//) # leave path alone if it has a scheme
uri
else
uri = path.join(@getPath(), uri) unless fs.isAbsolute(uri)
else if projectPath = @getPath()
uri = path.join(projectPath, uri) unless fs.isAbsolute(uri)
fs.absolute(uri)
# Public: Make the given path relative to the project directory.