File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -94,14 +94,21 @@ func AbsURL(pageURL string, relURL string) string {
9494 if err != nil {
9595 return ``
9696 }
97- siteURL := urlInfo .Scheme + `://` + urlInfo .Host
97+ return AbsURLx (urlInfo , relURL , true )
98+ }
99+
100+ func AbsURLx (pageURLInfo * url.URL , relURL string , onlyRelative ... bool ) string {
101+ if (len (onlyRelative ) == 0 || ! onlyRelative [0 ]) && strings .Contains (relURL , `://` ) {
102+ return relURL
103+ }
104+ siteURL := pageURLInfo .Scheme + `://` + pageURLInfo .Host
98105 if strings .HasPrefix (relURL , `/` ) {
99106 return siteURL + relURL
100107 }
101108 for strings .HasPrefix (relURL , `./` ) {
102109 relURL = strings .TrimPrefix (relURL , `./` )
103110 }
104- urlPath := path .Dir (urlInfo .Path )
111+ urlPath := path .Dir (pageURLInfo .Path )
105112 for strings .HasPrefix (relURL , `../` ) {
106113 urlPath = path .Dir (urlPath )
107114 relURL = strings .TrimPrefix (relURL , `../` )
You can’t perform that action at this time.
0 commit comments