Skip to content

Commit

Permalink
Merge pull request #1 from ada-url/update-readme
Browse files Browse the repository at this point in the history
refactor: small touches to readme and files
  • Loading branch information
lemire committed May 16, 2023
2 parents 2296304 + 8dcd9f8 commit a639c04
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 31 deletions.
21 changes: 21 additions & 0 deletions .github/update-ada.sh
Original file line number Diff line number Diff line change
@@ -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"
36 changes: 36 additions & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
@@ -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
23 changes: 19 additions & 4 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -17,5 +33,4 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3
- name: Test
run: |
go test
run: go test
55 changes: 28 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
```

0 comments on commit a639c04

Please sign in to comment.