Skip to content

Commit

Permalink
Merge pull request #328 from exercism/fix-url
Browse files Browse the repository at this point in the history
append solution URL path consistently
  • Loading branch information
kytrinyx committed May 30, 2016
2 parents 10b3ef4 + b5d1f5e commit 56b4be8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cmd/submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmd
import (
"fmt"
"log"
"net/url"
"os"
"path/filepath"

Expand Down Expand Up @@ -99,8 +100,10 @@ func Submit(ctx *cli.Context) error {
log.Fatal(err)
}

solutionURL, _ := url.Parse(c.API)
solutionURL.Path += fmt.Sprintf("tracks/%s/exercises/%s", iteration.TrackID, iteration.Problem)
fmt.Printf("Your %s solution for %s has been submitted. View it here:\n%s\n\n", submission.Language, submission.Name, submission.URL)
fmt.Printf("See related solutions and get involved here:\n%stracks/%s/exercises/%s\n\n", c.API, iteration.TrackID, iteration.Problem)
fmt.Printf("See related solutions and get involved here:\n%s\n\n", solutionURL)

return nil
}
9 changes: 9 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"io"
"log"
"net/url"
"os"
"strings"

Expand Down Expand Up @@ -172,6 +173,14 @@ func (c *Config) setDefaults() error {
c.XAPI = hostXAPI
}

if _, err := url.Parse(c.API); err != nil {
return fmt.Errorf("invalid API URL %s", err)
}

if _, err := url.Parse(c.XAPI); err != nil {
return fmt.Errorf("invalid xAPI URL %s", err)
}

c.Dir = paths.Exercises(c.Dir)

return nil
Expand Down

0 comments on commit 56b4be8

Please sign in to comment.