Skip to content

Commit 664569a

Browse files
committed
CI test for update as Raku community module
1 parent 4c06632 commit 664569a

File tree

13 files changed

+339
-104
lines changed

13 files changed

+339
-104
lines changed

.github/workflows/linux.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Linux
2+
3+
on:
4+
push:
5+
branches:
6+
- '*'
7+
tags-ignore:
8+
- '*'
9+
pull_request:
10+
11+
jobs:
12+
raku:
13+
strategy:
14+
matrix:
15+
os:
16+
- ubuntu-latest
17+
raku-version:
18+
- 'latest'
19+
runs-on: ${{ matrix.os }}
20+
steps:
21+
- uses: actions/checkout@v3
22+
- uses: Raku/setup-raku@v1
23+
with:
24+
raku-version: ${{ matrix.raku-version }}
25+
- name: Run Special Tests
26+
run: raku run-tests -i

.github/workflows/macos.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: MacOS
2+
3+
on:
4+
push:
5+
branches:
6+
- '*'
7+
tags-ignore:
8+
- '*'
9+
pull_request:
10+
11+
jobs:
12+
raku:
13+
strategy:
14+
matrix:
15+
os:
16+
- macos-latest
17+
raku-version:
18+
- 'latest'
19+
runs-on: ${{ matrix.os }}
20+
steps:
21+
- uses: actions/checkout@v3
22+
- uses: Raku/setup-raku@v1
23+
with:
24+
raku-version: ${{ matrix.raku-version }}
25+
- name: Run Special Tests
26+
run: raku run-tests -i

.github/workflows/test.yaml

Lines changed: 0 additions & 11 deletions
This file was deleted.

.github/workflows/windows.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Windows
2+
3+
on:
4+
push:
5+
branches:
6+
- '*'
7+
tags-ignore:
8+
- '*'
9+
pull_request:
10+
11+
jobs:
12+
raku:
13+
strategy:
14+
matrix:
15+
os:
16+
- windows-latest
17+
raku-version:
18+
- 'latest'
19+
runs-on: ${{ matrix.os }}
20+
steps:
21+
- uses: actions/checkout@v3
22+
- uses: Raku/setup-raku@v1
23+
with:
24+
raku-version: ${{ matrix.raku-version }}
25+
- name: Run Special Tests
26+
run: raku run-tests -i

Changes

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Revision history for URI::Encode
2+
3+
{{$NEXT}}
4+
- Use modern file extensions
5+
- Add seperate CI badges for each OS
6+
- Some code modernization
7+
- Initial version using App::Mi6 release logic

META6.json

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
{
2-
"perl" : "6.*",
3-
"name" : "URI::Encode",
4-
"version" : "0.09",
5-
"description" : "Encode and decode URIs according to RFC 3986",
6-
"authors" : [ "David Farrell", "Raku community" ],
7-
"auth": "zef:raku-community-modules",
8-
"test-depends" : [
9-
"Test"
10-
],
11-
"depends" : [ ],
12-
"provides" : {
13-
"URI::Encode" : "lib/URI/Encode.pm6"
14-
},
15-
"source-url" : "https://github.com/raku-community-modules/URI-Encode",
16-
"support": {
17-
"source": "[email protected]:raku-community-modules/URI-Encode.git",
18-
"bugtracker": "https://github.com/raku-community-modules/URI-Encode/issues"
19-
}
2+
"auth": "zef:raku-community-modules",
3+
"authors": [
4+
"David Farrell",
5+
"Raku community"
6+
],
7+
"build-depends": [
8+
],
9+
"depends": [
10+
],
11+
"description": "a Raku module for encoding / decoding URIs",
12+
"license": "FreeBSD",
13+
"name": "URI::Encode",
14+
"perl": "6.*",
15+
"provides": {
16+
"URI::Encode": "lib/URI/Encode.rakumod"
17+
},
18+
"resources": [
19+
],
20+
"source-url": "https://github.com/raku-community-modules/URI-Encode.git",
21+
"tags": [
22+
],
23+
"test-depends": [
24+
],
25+
"version": "0.09"
2026
}

README.md

Lines changed: 44 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,58 @@
1-
# URI::Encode [![Tests on source](https://github.com/raku-community-modules/URI-Encode/actions/workflows/test.yaml/badge.svg)](https://github.com/raku-community-modules/URI-Encode/actions/workflows/test.yaml)
1+
[![Actions Status](https://github.com/raku-community-modules/URI-Encode/actions/workflows/linux.yml/badge.svg)](https://github.com/raku-community-modules/URI-Encode/actions) [![Actions Status](https://github.com/raku-community-modules/URI-Encode/actions/workflows/macos.yml/badge.svg)](https://github.com/raku-community-modules/URI-Encode/actions) [![Actions Status](https://github.com/raku-community-modules/URI-Encode/actions/workflows/windows.yml/badge.svg)](https://github.com/raku-community-modules/URI-Encode/actions)
22

3-
A Raku module for encoding / decoding URIs
3+
NAME
4+
====
45

5-
# Synopsis
6+
URI::Encode - a Raku module for encoding / decoding URIs
67

7-
use URI::Encode;
8+
SYNOPSIS
9+
========
810

9-
# for encoding whole URIs, ignores reserved chars: :/?#[]@!$&'()*+,;=
10-
my $encoded_uri = uri_encode('http://www.example.com/?name=john doe&age=54');
11+
```raku
12+
use URI::Encode;
1113

12-
# encode every reserved char
13-
my $encoded_uri_component = uri_encode_component('some text/to encode+ safely');
14+
# for encoding whole URIs, ignores reserved chars: :/?#[]@!$&'()*+,;=
15+
my $encoded_uri = uri_encode('http://www.example.com/?name=john doe&age=54');
1416

15-
# remove percent encoding
16-
my $decoded_uri = uri_decode('http://www.example.com/?name=john%20doe&age=54');
17+
# encode every reserved char
18+
my $encoded_uri_component = uri_encode_component('some text/to encode+ safely');
1719

18-
# provided for symmetry, is the same as uri_decode()
19-
my $decoded_component = uri_decode_component('some%20text%2Fto%20%2B%20safely');
20+
# remove percent encoding
21+
my $decoded_uri = uri_decode('http://www.example.com/?name=john%20doe&age=54');
2022

21-
## See also
23+
# provided for symmetry, is the same as uri_decode()
24+
my $decoded_component = uri_decode_component('some%20text%2Fto%20%2B%20safely');
25+
```
2226

23-
[URI](https://raku.land/github:raku-community-modules/URI) is another
24-
implementation that covers this area, including encoding and decoding of URIs.
27+
DESCRIPTION
28+
===========
2529

26-
## Author
30+
URI::Encode is a module that exports four subroutines:
2731

28-
David Farrell, 2015; lately maintained by the Raku community adoption center.
32+
* uri_encode - encode a whole URI
2933

30-
## License
34+
* uri_encode_component - encode every reserved char
3135

32-
FreeBSD - see [LICENSE](LICENSE)
36+
* uri_decode - decode a whole URI
37+
38+
* uri_decode_component - decode every reserved char
39+
40+
SEE ALSo
41+
========
42+
43+
[`URI`](https://raku.land/github:raku-community-modules/URI) is another implementation that covers this area, including encoding and decoding of URIs.
44+
45+
AUTHOR
46+
======
47+
48+
David Farrell
49+
50+
COPYRIGHT AND LICENSE
51+
=====================
52+
53+
Copyright 2014 - 2015 David Farrell
54+
55+
Copyright 2016 - 2024 Raku Community
56+
57+
This library is free software; you can redistribute it and/or modify it under the FreeBSD license.
3358

dist.ini

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name = URI::Encode
2+
3+
[ReadmeFromPod]
4+
filename = lib/URI/Encode.rakumod
5+
6+
[UploadToZef]
7+
8+
[Badges]
9+
provider = github-actions/linux.yml
10+
provider = github-actions/macos.yml
11+
provider = github-actions/windows.yml

lib/URI/Encode.pm6

Lines changed: 0 additions & 45 deletions
This file was deleted.

lib/URI/Encode.rakumod

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
use v6.c; # required for correct execution
2+
3+
my $RFC3986_unreserved := rx/<[0..9A..Za..z\-.~_]>/;
4+
my $RFC3986_reserved := rx/<[:/?#\[\]@!$&'()*+,;=]>/;
5+
6+
# for uri_decode
7+
my %escapes = (^256).map: {
8+
sprintf("%%%02X", $_) => chr($_)
9+
unless chr($_) ~~ /$RFC3986_unreserved/;
10+
}
11+
12+
my sub enc (Str:D $m) {
13+
$m.encode.list.map(*.fmt('%%%02X')).join
14+
}
15+
16+
sub uri_encode (Str:D $text) is export {
17+
$text.comb.map({
18+
if $RFC3986_unreserved || $RFC3986_reserved {
19+
$_
20+
}
21+
else {
22+
&enc($_)
23+
}
24+
}).join
25+
}
26+
27+
sub uri_encode_component (Str:D $text) is export {
28+
$text.comb.map({
29+
if $RFC3986_unreserved {
30+
$_
31+
}
32+
else {
33+
enc($_)
34+
}
35+
}).join
36+
}
37+
38+
my sub dec ($m) {
39+
Buf.new($m<bit>.list.map({:16($_.Str)})).decode
40+
}
41+
42+
sub uri_decode (Str:D $text) is export {
43+
$text.subst(/[\%$<bit>=[<[0..9A..Fa..f]>** 2]]+/, &dec, :g)
44+
}
45+
46+
sub uri_decode_component (Str:D $text) is export {
47+
$text.subst(/[\%$<bit>=[<[0..9A..Fa..f]>** 2]]+/, &dec, :g)
48+
}
49+
50+
=begin pod
51+
52+
=head1 NAME
53+
54+
URI::Encode - a Raku module for encoding / decoding URIs
55+
56+
=head1 SYNOPSIS
57+
58+
=begin code :lang<raku>
59+
60+
use URI::Encode;
61+
62+
# for encoding whole URIs, ignores reserved chars: :/?#[]@!$&'()*+,;=
63+
my $encoded_uri = uri_encode('http://www.example.com/?name=john doe&age=54');
64+
65+
# encode every reserved char
66+
my $encoded_uri_component = uri_encode_component('some text/to encode+ safely');
67+
68+
# remove percent encoding
69+
my $decoded_uri = uri_decode('http://www.example.com/?name=john%20doe&age=54');
70+
71+
# provided for symmetry, is the same as uri_decode()
72+
my $decoded_component = uri_decode_component('some%20text%2Fto%20%2B%20safely');
73+
74+
=end code
75+
76+
=head1 DESCRIPTION
77+
78+
URI::Encode is a module that exports four subroutines:
79+
80+
=item uri_encode - encode a whole URI
81+
=item uri_encode_component - encode every reserved char
82+
=item uri_decode - decode a whole URI
83+
=item uri_decode_component - decode every reserved char
84+
85+
=head1 SEE ALSo
86+
87+
L<C<URI>|https://raku.land/github:raku-community-modules/URI> is another
88+
implementation that covers this area, including encoding and decoding of
89+
URIs.
90+
91+
=head1 AUTHOR
92+
93+
David Farrell
94+
95+
=head1 COPYRIGHT AND LICENSE
96+
97+
Copyright 2014 - 2015 David Farrell
98+
99+
Copyright 2016 - 2024 Raku Community
100+
101+
This library is free software; you can redistribute it and/or modify it under the FreeBSD license.
102+
103+
=end pod
104+
105+
# vim: expandtab shiftwidth=4

0 commit comments

Comments
 (0)