Skip to content

Commit 10a564a

Browse files
committed
Convert absolute channel or repository path to file:// URL
1 parent 8c74722 commit 10a564a

2 files changed

Lines changed: 33 additions & 19 deletions

File tree

package_control/commands/add_channel_command.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import sublime
44
import sublime_plugin
55

6+
from os.path import isabs
7+
68
from ..console_write import console_write
79
from ..settings import pc_settings_filename
810
from ..show_error import show_error
@@ -31,15 +33,20 @@ def run(self, url=None, unattended=False):
3133
url = url.strip()
3234

3335
if re.match(r'^(?:file:///|https?://)', url, re.I) is None:
34-
output_fn = console_write if unattended else show_error
35-
output_fn(
36-
'''
37-
Unable to add the channel "%s" since it does not appear to be
38-
served via HTTP (http:// or https://).
39-
''',
40-
url
41-
)
42-
return
36+
if not isabs(url):
37+
output_fn = console_write if unattended else show_error
38+
output_fn(
39+
'''
40+
Unable to add the channel "%s" since it does not appear to be
41+
a local URL (file://) or served via HTTP (http:// or https://).
42+
''',
43+
url
44+
)
45+
return
46+
47+
if url[0] != "/":
48+
url = "/" + url.replace("\\", "/")
49+
url = "file://" + url
4350

4451
settings = sublime.load_settings(pc_settings_filename())
4552
channels = settings.get('channels')

package_control/commands/add_repository_command.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import sublime
44
import sublime_plugin
55

6+
from os.path import isabs
7+
68
from ..console_write import console_write
79
from ..settings import pc_settings_filename
810
from ..show_error import show_error
@@ -31,15 +33,20 @@ def run(self, url=None, unattended=False):
3133
url = url.strip()
3234

3335
if re.match(r'^(?:file:///|https?://)', url, re.I) is None:
34-
output_fn = console_write if unattended else show_error
35-
output_fn(
36-
'''
37-
Unable to add the repository "%s" since it does not appear to
38-
be served via HTTP (http:// or https://).
39-
''',
40-
url
41-
)
42-
return
36+
if not isabs(url):
37+
output_fn = console_write if unattended else show_error
38+
output_fn(
39+
'''
40+
Unable to add the repository "%s" since it does not appear to
41+
be a local URL (file://) or served via HTTP (http:// or https://).
42+
''',
43+
url
44+
)
45+
return
46+
47+
if url[0] != "/":
48+
url = "/" + url.replace("\\", "/")
49+
url = "file://" + url
4350

4451
settings = sublime.load_settings(pc_settings_filename())
4552
repositories = settings.get('repositories')
@@ -54,7 +61,7 @@ def run(self, url=None, unattended=False):
5461
return
5562

5663
sublime.active_window().show_input_panel(
57-
'GitHub, GitLab or BitBucket Web URL, or Custom JSON Repository URL',
64+
'GitHub, GitLab, BitBucket or JSON repository URL',
5865
'',
5966
self.run,
6067
None,

0 commit comments

Comments
 (0)