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/.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 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 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 ```