mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2025-01-05 22:04:34 +03:00
Fix Project::relativePath w/ URLs
This commit is contained in:
parent
28d617e799
commit
587ebd7538
@ -486,6 +486,11 @@ describe "Project", ->
|
|||||||
randomPath = path.join("some", "random", "path")
|
randomPath = path.join("some", "random", "path")
|
||||||
expect(atom.project.relativizePath(randomPath)).toEqual [null, randomPath]
|
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)", ->
|
describe ".contains(path)", ->
|
||||||
it "returns whether or not the given path is in one of the root directories", ->
|
it "returns whether or not the given path is in one of the root directories", ->
|
||||||
rootPath = atom.project.getPaths()[0]
|
rootPath = atom.project.getPaths()[0]
|
||||||
|
@ -288,7 +288,6 @@ class Project extends Model
|
|||||||
# * `relativePath` {String} The relative path from the project directory to
|
# * `relativePath` {String} The relative path from the project directory to
|
||||||
# the given path.
|
# the given path.
|
||||||
relativizePath: (fullPath) ->
|
relativizePath: (fullPath) ->
|
||||||
return fullPath if fullPath?.match(/[A-Za-z0-9+-.]+:\/\//) # leave path alone if it has a scheme
|
|
||||||
for rootDirectory in @rootDirectories
|
for rootDirectory in @rootDirectories
|
||||||
relativePath = rootDirectory.relativize(fullPath)
|
relativePath = rootDirectory.relativize(fullPath)
|
||||||
return [rootDirectory.getPath(), relativePath] unless relativePath is fullPath
|
return [rootDirectory.getPath(), relativePath] unless relativePath is fullPath
|
||||||
|
Loading…
Reference in New Issue
Block a user