File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,8 @@ def path_to_site_root(config, page_path)
2121 ascents = number_of_ascents_to_site_root . zero? ? [ "." ] : number_of_ascents_to_site_root . times . collect { ".." }
2222 path_to_site_root = ascents . join ( "/" ) . concat ( "/" )
2323 else
24- path_to_site_root = "/"
24+ middleman_http_prefix = config [ :http_prefix ]
25+ path_to_site_root = middleman_http_prefix . end_with? ( "/" ) ? middleman_http_prefix : "#{ middleman_http_prefix } /"
2526 end
2627 path_to_site_root
2728 end
Original file line number Diff line number Diff line change 3131 it "calculates the path from a page to the site root when using absolute links" do
3232 page_path = "/documentation/introduction/index.html"
3333
34- config = { }
34+ config = {
35+ http_prefix : "/" , # This is Middleman's default setting.
36+ }
3537
3638 path_to_site_root = path_to_site_root ( config , page_path )
3739 expect ( path_to_site_root ) . to eql ( "/" )
3840 end
3941
42+ it "calculates the path from a page to the site root when a middleman http prefix" do
43+ page_path = "/bananas/documentation/introduction/index.html"
44+
45+ config = {
46+ http_prefix : "/bananas" ,
47+ }
48+
49+ path_to_site_root = path_to_site_root ( config , page_path )
50+ expect ( path_to_site_root ) . to eql ( "/bananas/" )
51+ end
52+
4053 it "calculates the path from a page to the site root when using relative links" do
4154 page_path = "/documentation/introduction/index.html"
4255
You can’t perform that action at this time.
0 commit comments