File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change 66 "errors"
77 "fmt"
88 "net/url"
9+ "strings"
910 "time"
1011
1112 "github.com/icinga/icinga-go-library/database"
@@ -37,19 +38,17 @@ type Event struct {
3738
3839// CompleteURL prefixes the URL with the given Icinga Web 2 base URL unless it already carries a URL or is empty.
3940func (e * Event ) CompleteURL (icingaWebBaseUrl string ) {
40- // Nothing to do for an empty URL.
4141 if e .URL == "" {
4242 return
4343 }
4444
45- // If the event carries a valid URL w/ a scheme, use this.
46- if eventUrl , err := url .Parse (e .URL ); err == nil && eventUrl .Scheme != "" {
47- return
45+ if ! strings .HasSuffix (icingaWebBaseUrl , "/" ) {
46+ icingaWebBaseUrl += "/"
4847 }
4948
50- // If the event carries something, put it behind the base URL.
51- if baseUrl , err := url . Parse ( icingaWebBaseUrl ); err == nil {
52- e .URL = baseUrl . JoinPath ( e .URL ). String ()
49+ u , err := url . Parse ( e . URL )
50+ if err != nil || u . Scheme == "" {
51+ e .URL = icingaWebBaseUrl + e .URL
5352 }
5453}
5554
You can’t perform that action at this time.
0 commit comments