feat: SlickVPN Support (#961)
- `internal/updater/html` package - Add unit tests for slickvpn updating code - Change shared html package to be more share-able - Split html utilities in multiple files - Fix processing .ovpn files with prefix space Authored by @Rohaq Co-authored-by: Quentin McGaw <quentin.mcgaw@gmail.com>
This commit is contained in:
27
internal/updater/html/errors.go
Normal file
27
internal/updater/html/errors.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package html
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
|
||||
"golang.org/x/net/html"
|
||||
)
|
||||
|
||||
func WrapError(sentinelError error, node *html.Node) error {
|
||||
return fmt.Errorf("%w: in HTML code: %s",
|
||||
sentinelError, mustRenderHTML(node))
|
||||
}
|
||||
|
||||
func WrapWarning(warning string, node *html.Node) string {
|
||||
return fmt.Sprintf("%s: in HTML code: %s",
|
||||
warning, mustRenderHTML(node))
|
||||
}
|
||||
|
||||
func mustRenderHTML(node *html.Node) (rendered string) {
|
||||
stringBuffer := bytes.NewBufferString("")
|
||||
err := html.Render(stringBuffer, node)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return stringBuffer.String()
|
||||
}
|
||||
Reference in New Issue
Block a user