diff --git a/.github/workflows_json/release.json b/.github/workflows/release.json similarity index 100% rename from .github/workflows_json/release.json rename to .github/workflows/release.json diff --git a/.github/workflows_json/test.json b/.github/workflows/test.json similarity index 96% rename from .github/workflows_json/test.json rename to .github/workflows/test.json index d8fb271..bb23b94 100644 --- a/.github/workflows_json/test.json +++ b/.github/workflows/test.json @@ -2,8 +2,8 @@ "name": "test", "on": { "push": { - "branches": [ - "dev" + "branches-ignore": [ + "master" ], "paths-ignore": [ ".git*", @@ -13,8 +13,7 @@ }, "pull_request": { "branches": [ - "master", - "dev" + "master" ], "paths-ignore": [ ".git*", diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index a7dd708..de841c1 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,8 +1,8 @@ name: test on: push: - branches: - - dev + branches-ignore: + - master paths-ignore: - .git* - '**.md' @@ -10,7 +10,6 @@ on: pull_request: branches: - master - - dev paths-ignore: - .git* - '**.md' diff --git a/.github/workflows/to_yaml.sh b/.github/workflows/to_yaml.sh new file mode 100644 index 0000000..cea5c29 --- /dev/null +++ b/.github/workflows/to_yaml.sh @@ -0,0 +1,8 @@ +#!/bin/sh +set -eu + +cd ${0%/*} + +for _v in $(find ./ -maxdepth 1 -type f -name '*.json'); do + yq -I 4 -o y ${_v} | head -c -1 > ${_v%.*}.yaml +done; unset _v \ No newline at end of file diff --git a/.github/workflows_json/to_yaml.sh b/.github/workflows_json/to_yaml.sh deleted file mode 100644 index 4878624..0000000 --- a/.github/workflows_json/to_yaml.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -set -eu - -cd ${0%/*} - -yq -o y -I 4 ./${1}.json | head -c -1 > ../workflows/${1}.yaml \ No newline at end of file diff --git a/README.md b/README.md index 2e658c3..dee291c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # **Arduino Percent** ![actions:test](https://github.com/dojyorin/arduino_percent/actions/workflows/test.yaml/badge.svg) ![actions:release](https://github.com/dojyorin/arduino_percent/actions/workflows/release.yaml/badge.svg) +![shields:license](https://img.shields.io/github/license/dojyorin/arduino_percent) +![shields:release](https://img.shields.io/github/release/dojyorin/arduino_percent) Convert between URL-unsafe string and percent encoded string. Easily convert to percent encoded string. diff --git a/library.properties b/library.properties index 768cc78..b4ad74b 100644 --- a/library.properties +++ b/library.properties @@ -1,6 +1,6 @@ name=percent_encode author=dojyorin -version=2.0.1 +version=2.0.2 architectures=* includes=arduino_percent.hpp sentence=Convert between URL-unsafe string and percent encoded string. diff --git a/src/percent.cpp b/src/percent.cpp index d329925..234c737 100644 --- a/src/percent.cpp +++ b/src/percent.cpp @@ -1,8 +1,8 @@ #include "./arduino_percent.hpp" namespace{ - constexpr char symbols[] = "0123456789ABCDEF"; - constexpr char unreserved[] = "-._~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; + constexpr char CODE[] = "0123456789ABCDEF"; + constexpr char UNRESERVED[] = "-._~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; uint8_t indexOf(char search){ if('`' < search){ @@ -10,7 +10,7 @@ namespace{ } for(uint8_t i = 0; i < 16; i++){ - if(symbols[i] == search){ + if(::CODE[i] == search){ return i; } } @@ -19,7 +19,7 @@ namespace{ } bool isUnreserved(char search){ - for(const auto &v: unreserved){ + for(const auto &v: ::UNRESERVED){ if(v == search){ return true; } @@ -31,13 +31,13 @@ namespace{ void percent::encode(const char* input, char* output){ while(*input != '\0'){ - if(isUnreserved(*input)){ + if(::isUnreserved(*input)){ *output++ = *input; } else{ *output++ = '%'; - *output++ = symbols[*input >> 0x04]; - *output++ = symbols[*input & 0x0F]; + *output++ = ::CODE[*input >> 0x04]; + *output++ = ::CODE[*input & 0x0F]; } input++; @@ -50,7 +50,7 @@ size_t percent::encodeLength(const char* input){ size_t length = 0; while(*input != '\0'){ - length += isUnreserved(*input++) ? 1 : 3; + length += ::isUnreserved(*input++) ? 1 : 3; } return length + 1; @@ -59,7 +59,7 @@ size_t percent::encodeLength(const char* input){ void percent::decode(const char* input, char* output){ while(*input != '\0'){ if(*input == '%'){ - *output++ = (indexOf(*++input) << 4) + indexOf(*++input); + *output++ = (::indexOf(*++input) << 4) + ::indexOf(*++input); } else{ *output++ = *input;