From 4b741b52a635e76165a079411ff7c1f211f34b30 Mon Sep 17 00:00:00 2001 From: Benji Hooper Date: Thu, 23 Aug 2018 11:48:35 +0100 Subject: [PATCH] Add ParseBytes func to Parser --- parser.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/parser.go b/parser.go index 2e9edd5..90c38ca 100644 --- a/parser.go +++ b/parser.go @@ -57,6 +57,17 @@ func (parser *Parser) Parse(path string) error { return parser.rt.run(string(contents)) } +// ParseBytes loads a proxy auto-config (PAC) file using the given byte array +func (parser *Parser) ParseBytes(contents []byte) error { + if !parser.initialised { + if err := parser.init(); err != nil { + return err + } + } + + return parser.rt.run(string(contents)) +} + // ParseUrl downloads and parses a proxy auto-config (PAC) file using the given // URL returning an error if the file fails to load. func (parser *Parser) ParseUrl(url string) error {