File tree Expand file tree Collapse file tree
lib/jekyll-github-metadata Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,6 +12,10 @@ class << self
1212 'SUBDOMAIN_ISOLATION' => 'false' . freeze
1313 } . freeze
1414
15+ # Whether the GitHub instance supports HTTPS
16+ # Note: this will be the same as how sites are served in Enterprise,
17+ # but may be different from how sites are served on GitHub.com.
18+ # See Repository#url_scheme
1519 def ssl?
1620 env_var ( 'SSL' ) == 'true' || test?
1721 end
Original file line number Diff line number Diff line change @@ -106,13 +106,17 @@ def primary?
106106 end
107107 end
108108
109+ # In enterprise, the site's scheme will be the same as the instance's
110+ # In dotcom, this will be `https` for GitHub-owned sites that end with
111+ # `.github.com` and will be `http` for all other sites.
112+ # Note: This is not the same as *instance*'s scheme, which may differ
109113 def url_scheme
110- if domain . end_with? ( ".github.com" . freeze )
111- "https" . freeze
112- elsif cname
113- "http"
114- else
114+ if Pages . enterprise?
115115 Pages . scheme
116+ elsif owner == 'github' && domain . end_with? ( '.github.com' )
117+ 'https'
118+ else
119+ 'http'
116120 end
117121 end
118122
Original file line number Diff line number Diff line change 4646 end
4747
4848 it "returns Pages.scheme for the scheme" do
49- expect ( repo . url_scheme ) . to eql ( Jekyll :: GitHubMetadata :: Pages . scheme )
49+ expect ( repo . url_scheme ) . to eql ( "http" )
5050 end
5151
5252 it "uses Pages.scheme to determine scheme for domain" do
53- expect ( repo . pages_url ) . to eql ( "#{ Jekyll ::GitHubMetadata ::Pages . scheme } ://parkr.github.io" )
53+ expect ( repo . pages_url ) . to eql ( "http://parkr.github.io" )
54+ end
55+
56+ context "on enterprise" do
57+ it "uses Pages.scheme to determine scheme for pages URL" do
58+ # With SSL=true
59+ with_env ( {
60+ "PAGES_ENV" => "enterprise" ,
61+ "SSL" => "true"
62+ } ) do
63+ expect ( Jekyll ::GitHubMetadata ::Pages . ssl? ) . to be ( true )
64+ expect ( Jekyll ::GitHubMetadata ::Pages . scheme ) . to eql ( "https" )
65+ expect ( repo . url_scheme ) . to eql ( "https" )
66+ end
67+
68+ # With no SSL
69+ with_env ( {
70+ "PAGES_ENV" => "enterprise"
71+ } ) do
72+ expect ( Jekyll ::GitHubMetadata ::Pages . ssl? ) . to be ( false )
73+ expect ( Jekyll ::GitHubMetadata ::Pages . scheme ) . to eql ( "http" )
74+ expect ( repo . url_scheme ) . to eql ( "http" )
75+ end
76+ end
5477 end
5578 end
5679end
You can’t perform that action at this time.
0 commit comments