From 3bd06d5bd289c036894930d0c1a1cc0c2570ff11 Mon Sep 17 00:00:00 2001 From: Yagiz Nizipli Date: Tue, 16 May 2023 18:09:40 -0400 Subject: [PATCH 1/3] refactor: small touches to readme and files --- .github/update-ada.sh | 21 +++++++++++++++++ README.md | 55 ++++++++++++++++++++++--------------------- 2 files changed, 49 insertions(+), 27 deletions(-) create mode 100755 .github/update-ada.sh diff --git a/.github/update-ada.sh b/.github/update-ada.sh new file mode 100755 index 0000000..cae14ff --- /dev/null +++ b/.github/update-ada.sh @@ -0,0 +1,21 @@ +#!/bin/sh +set -e + +BASE_DIR=$(pwd) +DEPENDENCIES_DIR="$BASE_DIR" + +WORKSPACE=$(mktemp -d 2> /dev/null || mktemp -d -t 'tmp') + +cleanup () { + EXIT_CODE=$? + [ -d "$WORKSPACE" ] && rm -rf "$WORKSPACE" + exit $EXIT_CODE +} + +trap cleanup INT TERM EXIT + +cd "$WORKSPACE" +curl -sL -o "ada" "https://github.com/ada-url/ada/releases/latest/download/singleheader.zip" +unzip ada +rm ada +cp * "$DEPENDENCIES_DIR" diff --git a/README.md b/README.md index a626f2b..892dae2 100644 --- a/README.md +++ b/README.md @@ -1,39 +1,40 @@ +# goada: Fast WHATWG URL library in Go +[![Go-CI](https://github.com/ada-url/goada/actions/workflows/ubuntu.yml/badge.svg)](https://github.com/ada-url/goada/actions/workflows/ubuntu.yml) +[![GoDoc](https://godoc.org/github.com/ada-url/goada?status.svg)](https://godoc.org/github.com/ada-url/goada) -# goada : fast WHATGL URL library in Go -[![Go-CI](https://github.com/ada-url/goada/actions/workflows/ubuntu.yml/badge.svg)](https://github.com/ada-url/goada/actions/workflows/ubuntu.yml) [![GoDoc](https://godoc.org/github.com/ada-url/goada?status.svg)](https://godoc.org/github.com/ada-url/goada) +The goada library provides support for the WHATWG URL standard in Go. -The goada library provides support for the WHATGL URL -standard in Go. +## Requirements + +- Go 1.20 or better. -Examples: +### Examples ```Go - url, nil := New("https:// www.GOoglé.com") - fmt.Println(url.Href()) // "https://www.xn--googl-fsa.com/" +url, nil := New("https:// www.GOoglé.com") +fmt.Println(url.Href()) // "https://www.xn--googl-fsa.com/" ``` -The standard `net/url` `Parse` function would refuse to parse the URL `"https:// www.GOoglé.com"` because it contains a tabulation character. Even if we remove the tabulation character, it would still parse it to an incorrect string as per the WHATGL URL standard (`https://www.GOogl%C3%A9.com`). - -## Requirements - -- Go 1.20 or better. +The standard `net/url` `Parse` function would refuse to parse the URL `"https:// www.GOoglé.com"` because it +contains a tabulation character. Even if we remove the tabulation character, it would still parse it to an incorrect +string as per the WHATGL URL standard (`https://www.GOogl%C3%A9.com`). -## Usage +### Usage ```Go - import ( - "github.com/ada-url/goada" - "fmt" - ) - - url, err := goada.New("https://www.GOogle.com") - if err != nil { - t.Error("Expected no error") - } - fmt.Println(url.Href()) // prints https://www.google.com/ - url.SetProtocol("http:") - url.SetHash("goada") - fmt.Println(url.Hash()) // prints #goada - fmt.Println(url.Href()) // prints http://www.google.com/#goada +import ( + "github.com/ada-url/goada" + "fmt" +) + +url, err := goada.New("https://www.GOogle.com") +if err != nil { + t.Error("Expected no error") +} +fmt.Println(url.Href()) // prints https://www.google.com/ +url.SetProtocol("http:") +url.SetHash("goada") +fmt.Println(url.Hash()) // prints #goada +fmt.Println(url.Href()) // prints http://www.google.com/#goada ``` From 70e93a6cf6e5201d10b854900d6f1dfd3d396e4d Mon Sep 17 00:00:00 2001 From: Yagiz Nizipli Date: Tue, 16 May 2023 18:16:26 -0400 Subject: [PATCH 2/3] build: update ubuntu workflow --- .github/workflows/ubuntu.yml | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 3f6cd05..6e8f369 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -1,6 +1,22 @@ -name: Go-CI +name: Ubuntu -on: [push, pull_request] +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + paths-ignore: + - '**.md' + push: + branches: + - main + paths-ignore: + - '**.md' + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: test: @@ -17,5 +33,4 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - name: Test - run: | - go test + run: go test From 8dcd9f858a1ab468b21627c7fcde59d0875ec11b Mon Sep 17 00:00:00 2001 From: Yagiz Nizipli Date: Tue, 16 May 2023 18:22:08 -0400 Subject: [PATCH 3/3] build: add macos workflow --- .github/workflows/macos.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/macos.yml diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml new file mode 100644 index 0000000..68121d6 --- /dev/null +++ b/.github/workflows/macos.yml @@ -0,0 +1,36 @@ +name: macOS + +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + paths-ignore: + - '**.md' + push: + branches: + - main + paths-ignore: + - '**.md' + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + test: + strategy: + matrix: + go-version: [1.20.x] + platform: [macos-latest] + runs-on: ${{ matrix.platform }} + steps: + - name: Install Go + uses: actions/setup-go@v3 + with: + go-version: ${{ matrix.go-version }} + - name: Checkout code + uses: actions/checkout@v3 + - name: Test + run: go test