mirror of
https://github.com/kjanat/articulate-parser.git
synced 2026-08-05 18:44:07 +02:00
fix(lint): resolve golangci-lint failures and modernize string handling
CI's golangci-lint (v2.12.2) job was failing with 14 issues, which blocked
the dependent test job. This addresses all of them:
- goconst: extract repeated string literals into constants
- format aliases ("md", "word", "htm") in the exporter factory
- "section" lesson type shared by markdown and HTML exporters
- default Articulate Rise base URL and host in the parser
- reuse existing itemType* constants in the markdown switch
- staticcheck (QF1012): replace buf.WriteString(fmt.Sprintf(...)) with
fmt.Fprintf(...) in the markdown exporter
Also drop the hardcoded `go: "1.24"` from .golangci.yml so the target Go
version is autodetected from go.mod.
This commit is contained in:
@@ -15,6 +15,14 @@ import (
|
||||
"github.com/kjanat/articulate-parser/internal/models"
|
||||
)
|
||||
|
||||
// Default endpoint configuration for the Articulate Rise API.
|
||||
const (
|
||||
// Root URL for the Articulate Rise API.
|
||||
defaultBaseURL = "https://rise.articulate.com"
|
||||
// Expected host for Articulate Rise share URLs.
|
||||
riseHost = "rise.articulate.com"
|
||||
)
|
||||
|
||||
// shareIDRegex is compiled once at package init for extracting share IDs from URIs.
|
||||
var shareIDRegex = regexp.MustCompile(`/share/([a-zA-Z0-9_-]+)`)
|
||||
|
||||
@@ -37,7 +45,7 @@ func NewArticulateParser(logger interfaces.Logger, baseURL string, timeout time.
|
||||
logger = NewNoOpLogger()
|
||||
}
|
||||
if baseURL == "" {
|
||||
baseURL = "https://rise.articulate.com"
|
||||
baseURL = defaultBaseURL
|
||||
}
|
||||
if timeout == 0 {
|
||||
timeout = 30 * time.Second
|
||||
@@ -132,7 +140,7 @@ func (p *ArticulateParser) extractShareID(uri string) (string, error) {
|
||||
}
|
||||
|
||||
// Validate that it's an Articulate Rise domain
|
||||
if parsedURL.Host != "rise.articulate.com" {
|
||||
if parsedURL.Host != riseHost {
|
||||
return "", fmt.Errorf("invalid domain for Articulate Rise URI: %s", parsedURL.Host)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user