discourse_theme 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a2c9de53be0837cfd21dcf4571ffc05bbc949a60
4
- data.tar.gz: 6decd445584fb6ea98456ab4b2cd401144dc5814
3
+ metadata.gz: 5018db22dc1253f3812b0b9d1904c7d23f88ecc8
4
+ data.tar.gz: 11d66ad3bcf8b5d598d719d8ecaa62e773a112db
5
5
  SHA512:
6
- metadata.gz: 7c47776ca992a4b4d24be957d2df4538377c2c4664c2b62549d4ffa889391b54f61bd3422712f043dca728db58552bbce6da36d7e5d9a577f2fc6e63a792d921
7
- data.tar.gz: 62110a8ee513708fc4c4f73d2b27f4161b76042cc89336582681239e92f489e43e2c1c06a148cec766b76c1322ebbc4f4aa15c17b5aa5b8ad4f13314038c1143
6
+ metadata.gz: dc69715ebf934735f5f78948ff3bacddc2af7326701f7494c69d786317cee651f0cd30c2a62eb7dc5ce0fb82bfa2387d22549bcd58c58456f1e92cdd7f3c989f
7
+ data.tar.gz: 1e2cdd532b2f17fcad4c71f8383a64b118b451905a8b0727394c5f3cec94041f8fb96593ccaf1d4e2570781764bf7ee36db5d150358b98e2b913ba9107a1e5e9
@@ -34,6 +34,15 @@ class DiscourseTheme::Cli
34
34
  api_key
35
35
  end
36
36
 
37
+ def is_https_redirect?(url)
38
+ url = URI.parse(url)
39
+ path = url.path
40
+ path = "/" if path.empty?
41
+ req = Net::HTTP::Get.new("/")
42
+ response = Net::HTTP.start(url.host, url.port) { |http| http.request(req) }
43
+ Net::HTTPRedirection === response && response['location'] =~ /^https/i
44
+ end
45
+
37
46
  def guess_url(settings)
38
47
  url = ENV['DISCOURSE_URL']
39
48
  if url
@@ -48,7 +57,15 @@ class DiscourseTheme::Cli
48
57
  if !url
49
58
  puts "No site found! Where would you like to synchronize the theme to: "
50
59
  url = STDIN.gets.strip
51
- url += "http://" unless url =~ /^https?:\/\//
60
+ url = "http://#{url}" unless url =~ /^https?:\/\//
61
+
62
+ # maybe this is an HTTPS redirect
63
+ uri = URI.parse(url)
64
+ if URI::HTTP === uri && uri.port == 80 && is_https_redirect?(url)
65
+ puts "Detected an #{url} is an HTTPS domain"
66
+ url = url.sub("http", "https")
67
+ end
68
+
52
69
  puts "Would you like me to store this site name at: #{SETTINGS_FILE}? (Yes|No)"
53
70
  answer = STDIN.gets.strip
54
71
  if answer =~ /y(es)?/i
@@ -1,3 +1,3 @@
1
1
  module DiscourseTheme
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: discourse_theme
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Saffron