diff options
| author | Christine Dodrill <me@christine.website> | 2018-10-04 18:46:19 -0700 |
|---|---|---|
| committer | Christine Dodrill <me@christine.website> | 2018-10-04 18:46:19 -0700 |
| commit | f865c279e58fe8a2287980d79c4f07646adab88c (patch) | |
| tree | e6d0b2144ffbb161f7fb0c12c6e4588566c86678 /tools/glue/vendor/github.com/cjoudrey/gluaurl | |
| parent | 1ea65cb9255af99adcf3cd8f55e6e2f336408a73 (diff) | |
| download | x-f865c279e58fe8a2287980d79c4f07646adab88c.tar.xz x-f865c279e58fe8a2287980d79c4f07646adab88c.zip | |
remove old stuff
Diffstat (limited to 'tools/glue/vendor/github.com/cjoudrey/gluaurl')
6 files changed, 0 insertions, 597 deletions
diff --git a/tools/glue/vendor/github.com/cjoudrey/gluaurl/.gitignore b/tools/glue/vendor/github.com/cjoudrey/gluaurl/.gitignore deleted file mode 100644 index daf913b..0000000 --- a/tools/glue/vendor/github.com/cjoudrey/gluaurl/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -# Compiled Object files, Static and Dynamic libs (Shared Objects) -*.o -*.a -*.so - -# Folders -_obj -_test - -# Architecture specific extensions/prefixes -*.[568vq] -[568vq].out - -*.cgo1.go -*.cgo2.c -_cgo_defun.c -_cgo_gotypes.go -_cgo_export.* - -_testmain.go - -*.exe -*.test -*.prof diff --git a/tools/glue/vendor/github.com/cjoudrey/gluaurl/.travis.yml b/tools/glue/vendor/github.com/cjoudrey/gluaurl/.travis.yml deleted file mode 100644 index 7a3d33a..0000000 --- a/tools/glue/vendor/github.com/cjoudrey/gluaurl/.travis.yml +++ /dev/null @@ -1,14 +0,0 @@ -language: go - -go: - - 1.3 - - 1.4 - -install: - - go get github.com/yuin/gopher-lua - -script: - - go test -v - -notifications: - email: false diff --git a/tools/glue/vendor/github.com/cjoudrey/gluaurl/LICENSE b/tools/glue/vendor/github.com/cjoudrey/gluaurl/LICENSE deleted file mode 100644 index 56a399a..0000000 --- a/tools/glue/vendor/github.com/cjoudrey/gluaurl/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2015 Christian Joudrey - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - diff --git a/tools/glue/vendor/github.com/cjoudrey/gluaurl/README.md b/tools/glue/vendor/github.com/cjoudrey/gluaurl/README.md deleted file mode 100644 index fc82b5f..0000000 --- a/tools/glue/vendor/github.com/cjoudrey/gluaurl/README.md +++ /dev/null @@ -1,109 +0,0 @@ -# gluaurl - -[](https://travis-ci.org/cjoudrey/gluaurl) - -gluahttp provides an easy way to parse and build URLs from within [GopherLua](https://github.com/yuin/gopher-lua). - -## Installation - -``` -go get github.com/cjoudrey/gluaurl -``` - -## Usage - -```go -import "github.com/yuin/gopher-lua" -import "github.com/cjoudrey/gluaurl" - -func main() { - L := lua.NewState() - defer L.Close() - - L.PreloadModule("url", gluaurl.Loader) - - if err := L.DoString(` - - local url = require("url") - - parsed_url = url.parse("http://example.com/") - - print(parsed_url.host) - - `); err != nil { - panic(err) - } -} -``` - -## API - -- [`url.parse(url)`](#urlparseurl) -- [`url.build(options)`](#urlbuildoptions) -- [`url.build_query_string(query_params)`](#urlbuild_query_stringquery_params) -- [`url.resolve(from, to)`](#urlresolvefrom-to) - -### url.parse(url) - -Parse URL into a table of key/value components. - -**Attributes** - -| Name | Type | Description | -| ------- | ------ | ----------- | -| url | String | URL to parsed | - -**Returns** - -Table with parsed URL or (nil, error message) - -| Name | Type | Description | -| -------- | ------ | ----------- | -| scheme | String | Scheme of the URL | -| username | String | Username | -| password | String | Password | -| host | String | Host and port of the URL | -| path | String | Path | -| query | String | Query string | -| fragment | String | Fragment | - -### url.build(options) - -Assemble a URL string from a table of URL components. - -**Attributes** - -| Name | Type | Description | -| ------- | ----- | ----------- | -| options | Table | Table with URL components, see [`url.parse`](#urlparseurl) for list of valid components | - -**Returns** - -String - -### url.build_query_string(query_params) - -Assemble table of query string parameters into a string. - -**Attributes** - -| Name | Type | Description | -| ------------ | ----- | ----------- | -| query_params | Table | Table with query parameters | - -**Returns** - -String - -### url.resolve(from, to) - -Take a base URL, and a href URL, and resolve them as a browser would for an anchor tag. - -| Name | Type | Description | -| ---- | ------ | ----------- | -| from | String | base URL | -| to | String | href URL | - -**Returns** - -String or (nil, error message) diff --git a/tools/glue/vendor/github.com/cjoudrey/gluaurl/gluaurl.go b/tools/glue/vendor/github.com/cjoudrey/gluaurl/gluaurl.go deleted file mode 100644 index 287769a..0000000 --- a/tools/glue/vendor/github.com/cjoudrey/gluaurl/gluaurl.go +++ /dev/null @@ -1,178 +0,0 @@ -package gluaurl - -import "github.com/yuin/gopher-lua" -import "net/url" -import "strings" -import "fmt" -import "sort" -import "regexp" - -var rBracket = regexp.MustCompile("\\[\\]$") - -func Loader(L *lua.LState) int { - mod := L.SetFuncs(L.NewTable(), map[string]lua.LGFunction{ - "parse": parse, - "build": build, - "build_query_string": buildQueryString, - "resolve": resolve, - }) - L.Push(mod) - return 1 -} - -func parse(L *lua.LState) int { - parsed := L.NewTable() - - url, err := url.Parse(L.CheckString(1)) - if err != nil { - L.Push(lua.LNil) - L.Push(lua.LString(fmt.Sprintf("%s", err))) - return 2 - } - - parsed.RawSetString("scheme", lua.LString(url.Scheme)) - - if url.User != nil { - parsed.RawSetString("username", lua.LString(url.User.Username())) - - if password, hasPassword := url.User.Password(); hasPassword { - parsed.RawSetString("password", lua.LString(password)) - } else { - parsed.RawSetString("password", lua.LNil) - } - - } else { - parsed.RawSetString("username", lua.LNil) - parsed.RawSetString("password", lua.LNil) - } - - parsed.RawSetString("host", lua.LString(url.Host)) - parsed.RawSetString("path", lua.LString(url.Path)) - parsed.RawSetString("query", lua.LString(url.RawQuery)) - parsed.RawSetString("fragment", lua.LString(url.Fragment)) - - L.Push(parsed) - - return 1 -} - -func build(L *lua.LState) int { - options := L.CheckTable(1) - - buildUrl := url.URL{} - - if scheme := options.RawGetString("scheme"); scheme != lua.LNil { - buildUrl.Scheme = scheme.String() - } - - if username := options.RawGetString("username"); username != lua.LNil { - if password := options.RawGetString("password"); password != lua.LNil { - buildUrl.User = url.UserPassword(username.String(), password.String()) - } else { - buildUrl.User = url.User(username.String()) - } - } - - if host := options.RawGetString("host"); host != lua.LNil { - buildUrl.Host = host.String() - } - - if path := options.RawGetString("path"); path != lua.LNil { - buildUrl.Path = path.String() - } - - if query := options.RawGetString("query"); query != lua.LNil { - buildUrl.RawQuery = query.String() - } - - if fragment := options.RawGetString("fragment"); fragment != lua.LNil { - buildUrl.Fragment = fragment.String() - } - - L.Push(lua.LString(buildUrl.String())) - - return 1 -} - -func buildQueryString(L *lua.LState) int { - options := L.CheckTable(1) - - ret := make([]string, 0) - - options.ForEach(func(key, value lua.LValue) { - toQueryString(key.String(), value, &ret) - }) - - sort.Strings(ret) - - L.Push(lua.LString(strings.Join(ret, "&"))) - - return 1 -} - -func toQueryString(prefix string, lv lua.LValue, ret *[]string) { - switch v := lv.(type) { - case lua.LBool: - *ret = append(*ret, url.QueryEscape(prefix)+"="+v.String()) - break - - case lua.LNumber: - *ret = append(*ret, url.QueryEscape(prefix)+"="+v.String()) - break - - case lua.LString: - *ret = append(*ret, url.QueryEscape(prefix)+"="+url.QueryEscape(v.String())) - break - - case *lua.LTable: - maxn := v.MaxN() - if maxn == 0 { - ret2 := make([]string, 0) - v.ForEach(func(key lua.LValue, value lua.LValue) { - toQueryString(prefix+"["+key.String()+"]", value, &ret2) - }) - sort.Strings(ret2) - *ret = append(*ret, strings.Join(ret2, "&")) - } else { - ret2 := make([]string, 0) - for i := 1; i <= maxn; i++ { - vi := v.RawGetInt(i) - - if rBracket.MatchString(prefix) { - ret2 = append(ret2, url.QueryEscape(prefix)+"="+vi.String()) - } else { - if vi.Type() == lua.LTTable { - toQueryString(fmt.Sprintf("%s[%d]", prefix, i-1), vi, &ret2) - } else { - toQueryString(prefix+"[]", vi, &ret2) - } - } - } - *ret = append(*ret, strings.Join(ret2, "&")) - } - break - } -} - -func resolve(L *lua.LState) int { - from := L.CheckString(1) - to := L.CheckString(2) - - fromUrl, err := url.Parse(from) - if err != nil { - L.Push(lua.LNil) - L.Push(lua.LString(fmt.Sprintf("%s", err))) - return 2 - } - - toUrl, err := url.Parse(to) - if err != nil { - L.Push(lua.LNil) - L.Push(lua.LString(fmt.Sprintf("%s", err))) - return 2 - } - - resolvedUrl := fromUrl.ResolveReference(toUrl).String() - L.Push(lua.LString(resolvedUrl)) - return 1 -} diff --git a/tools/glue/vendor/github.com/cjoudrey/gluaurl/gluaurl_test.go b/tools/glue/vendor/github.com/cjoudrey/gluaurl/gluaurl_test.go deleted file mode 100644 index a21a675..0000000 --- a/tools/glue/vendor/github.com/cjoudrey/gluaurl/gluaurl_test.go +++ /dev/null @@ -1,250 +0,0 @@ -package gluaurl - -import "github.com/yuin/gopher-lua" -import "testing" -import "os" -import "bytes" -import "io" -import "strings" - -func TestParse(t *testing.T) { - output, err := evalScript(` -local url = require("url") - -parsed = url.parse("http://bob:secret@example.com:8080/products?page=2#something") - -print(parsed.scheme) -print(parsed.username) -print(parsed.password) -print(parsed.host) -print(parsed.path) -print(parsed.query) -print(parsed.fragment) -`) - - if err != nil { - t.Errorf("Failed to evaluate script: %s", err) - } else { - if expected := `http -bob -secret -example.com:8080 -/products -page=2 -something -`; expected != output { - t.Errorf("Expected output does not match actual output\nExpected: %s\nActual: %s", expected, output) - } - } -} - -func TestParseOnlyHost(t *testing.T) { - output, err := evalScript(` -local url = require("url") - -parsed = url.parse("https://example.com") - -print(parsed.scheme) -print(parsed.username) -print(parsed.password) -print(parsed.host) -print(parsed.path) -print(parsed.query) -print(parsed.fragment) -`) - - if err != nil { - t.Errorf("Failed to evaluate script: %s", err) - } else { - if expected := `https -nil -nil -example.com - - - -`; expected != output { - t.Errorf("Expected output does not match actual output\nExpected: %s\nActual: %s", expected, output) - } - } -} - -func TestBuild(t *testing.T) { - output, err := evalScript(` -local url = require("url") - -built = url.build({ - scheme="https", - username="bob", - password="secret", - host="example.com:8080", - path="/products", - query="page=2", - fragment="something" -}) - -print(built) -`) - - if err != nil { - t.Errorf("Failed to evaluate script: %s", err) - } else { - if expected := `https://bob:secret@example.com:8080/products?page=2#something -`; expected != output { - t.Errorf("Expected output does not match actual output\nExpected: %s\nActual: %s", expected, output) - } - } -} - -func TestBuildEmpty(t *testing.T) { - output, err := evalScript(` -local url = require("url") - -built = url.build({}) - -print(built) -`) - - if err != nil { - t.Errorf("Failed to evaluate script: %s", err) - } else { - if expected := ` -`; expected != output { - t.Errorf("Expected output does not match actual output\nExpected: %s\nActual: %s", expected, output) - } - } -} - -func TestBuildQueryString(t *testing.T) { - output, err := evalScript(` -local url = require("url") - -function assert_query_string(options, expected, message) - actual = url.build_query_string(options) - - if expected ~= actual then - print("Failed to build '" .. message .. "'") - print("Expected:") - print(expected) - print("Actual:") - print(actual) - end -end - -assert_query_string( - {foo="bar", baz=42, quux="All your base are belong to us"}, - "baz=42&foo=bar&quux=All+your+base+are+belong+to+us", - "simple" -) - -assert_query_string( - {someName={1, 2, 3}, regularThing="blah"}, - "regularThing=blah&someName%5B%5D=1&someName%5B%5D=2&someName%5B%5D=3", - "with array" -) - -assert_query_string( - {foo={"a", "b", "c"}}, - "foo%5B%5D=a&foo%5B%5D=b&foo%5B%5D=c", - "with array of strings" -) - -assert_query_string( - {foo={"baz", 42, "All your base are belong to us"}}, - "foo%5B%5D=baz&foo%5B%5D=42&foo%5B%5D=All+your+base+are+belong+to+us", - "more array" -) - -assert_query_string( - {foo={bar="baz", beep=42, quux="All your base are belong to us"}}, - "foo%5Bbar%5D=baz&foo%5Bbeep%5D=42&foo%5Bquux%5D=All+your+base+are+belong+to+us", - "even more arrays" -) - -assert_query_string( - {a={1,2}, b={c=3, d={4,5}, e={ x={6}, y=7, z={8,9} }, f=true, g=false, h=""}, i={10,11}, j=true, k=false, l={"",0}, m="cowboy hat?" }, - "a%5B%5D=1&a%5B%5D=2&b%5Bc%5D=3&b%5Bd%5D%5B%5D=4&b%5Bd%5D%5B%5D=5&b%5Be%5D%5Bx%5D%5B%5D=6&b%5Be%5D%5By%5D=7&b%5Be%5D%5Bz%5D%5B%5D=8&b%5Be%5D%5Bz%5D%5B%5D=9&b%5Bf%5D=true&b%5Bg%5D=false&b%5Bh%5D=&i%5B%5D=10&i%5B%5D=11&j=true&k=false&l%5B%5D=&l%5B%5D=0&m=cowboy+hat%3F", - "huge structure" -) - -assert_query_string( - { a={0, { 1, 2 }, { 3, { 4, 5 }, { 6 } }, { b= { 7, { 8, 9 }, { { c=10, d=11 } }, { { 12 } }, { { { 13 } } }, { e= { f= { g={ 14, { 15 } } } } }, 16 } }, 17 } }, - "a%5B%5D=0&a%5B1%5D%5B%5D=1&a%5B1%5D%5B%5D=2&a%5B2%5D%5B%5D=3&a%5B2%5D%5B1%5D%5B%5D=4&a%5B2%5D%5B1%5D%5B%5D=5&a%5B2%5D%5B2%5D%5B%5D=6&a%5B3%5D%5Bb%5D%5B%5D=7&a%5B3%5D%5Bb%5D%5B1%5D%5B%5D=8&a%5B3%5D%5Bb%5D%5B1%5D%5B%5D=9&a%5B3%5D%5Bb%5D%5B2%5D%5B0%5D%5Bc%5D=10&a%5B3%5D%5Bb%5D%5B2%5D%5B0%5D%5Bd%5D=11&a%5B3%5D%5Bb%5D%5B3%5D%5B0%5D%5B%5D=12&a%5B3%5D%5Bb%5D%5B4%5D%5B0%5D%5B0%5D%5B%5D=13&a%5B3%5D%5Bb%5D%5B5%5D%5Be%5D%5Bf%5D%5Bg%5D%5B%5D=14&a%5B3%5D%5Bb%5D%5B5%5D%5Be%5D%5Bf%5D%5Bg%5D%5B1%5D%5B%5D=15&a%5B3%5D%5Bb%5D%5B%5D=16&a%5B%5D=17", - "nested arrays" -) - -assert_query_string( - { a= {1,2,3}, ["b[]"]= {4,5,6}, ["c[d]"]= {7,8,9}, e= { f= {10}, g= {11,12}, h= 13 } }, - "a%5B%5D=1&a%5B%5D=2&a%5B%5D=3&b%5B%5D=4&b%5B%5D=5&b%5B%5D=6&c%5Bd%5D%5B%5D=7&c%5Bd%5D%5B%5D=8&c%5Bd%5D%5B%5D=9&e%5Bf%5D%5B%5D=10&e%5Bg%5D%5B%5D=11&e%5Bg%5D%5B%5D=12&e%5Bh%5D=13", - "make sure params are not double-encoded" -) - -`) - - if err != nil { - t.Errorf("Failed to evaluate script: %s", err) - } else { - if expected := ``; expected != output { - t.Error(output) - } - } -} - -func TestResolve(t *testing.T) { - output, err := evalScript(` -local url = require("url") - -print(url.resolve('/one/two/three', 'four')) -print(url.resolve('http://example.com/', '/one')) -print(url.resolve('http://example.com/one', '/two')) -print(url.resolve('https://example.com/one', '//example2.com')) -`) - - if err != nil { - t.Errorf("Failed to evaluate script: %s", err) - } else { - if expected := `/one/two/four -http://example.com/one -http://example.com/two -https://example2.com -`; expected != output { - t.Errorf("Expected output does not match actual output\nExpected: %s\nActual: %s", expected, output) - } - } -} - -func evalScript(script string) (string, error) { - L := lua.NewState() - defer L.Close() - - L.PreloadModule("url", Loader) - - var err error - - out := captureStdout(func() { - err = L.DoString(script) - }) - - return out, err -} - -func captureStdout(inner func()) string { - oldStdout := os.Stdout - r, w, _ := os.Pipe() - os.Stdout = w - - outC := make(chan string) - go func() { - var buf bytes.Buffer - io.Copy(&buf, r) - outC <- buf.String() - }() - - inner() - - w.Close() - os.Stdout = oldStdout - out := strings.Replace(<-outC, "\r", "", -1) - - return out -} |
