|
| 1 | +<!-- |
| 2 | + Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + or more contributor license agreements. See the NOTICE file |
| 4 | + distributed with this work for additional information |
| 5 | + regarding copyright ownership. The ASF licenses this file |
| 6 | + to you under the Apache License, Version 2.0 (the |
| 7 | + "License"); you may not use this file except in compliance |
| 8 | + with the License. You may obtain a copy of the License at |
| 9 | +
|
| 10 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +
|
| 12 | + Unless required by applicable law or agreed to in writing, |
| 13 | + software distributed under the License is distributed on an |
| 14 | + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + KIND, either express or implied. See the License for the |
| 16 | + specific language governing permissions and limitations |
| 17 | + under the License. |
| 18 | +--> |
| 19 | + |
| 20 | +# gp_url_tools: Cloudberry extension providing functionality for working with URL addresses |
| 21 | + |
| 22 | +### Features |
| 23 | +`gp_url_tools` is an extension for the Cloudberry database that gives implementation |
| 24 | +for functions that encode/decode url/uri. |
| 25 | + |
| 26 | +### Functions |
| 27 | +The extension creates the `url_tools_schema` schema and adds four SQL functions: |
| 28 | + |
| 29 | +- `url_tools_schema.encode_url`/`.encode_uri` |
| 30 | + Encodes a text value for use as a URL/URI component by replacing reserved characters with percent-encoded sequences. |
| 31 | + |
| 32 | +- `url_tools_schema.decode_url`/`.decode_uri` |
| 33 | + Decodes percent-encoded sequences in a URL/URI-encoded text value back to their original characters (human-readable). |
| 34 | + |
| 35 | +### Usage |
| 36 | +```sql |
| 37 | +CREATE EXTENSION gp_url_tools; |
| 38 | +``` |
| 39 | +```sql |
| 40 | +SELECT url_tools_schema.encode_url('Hello World'); |
| 41 | +``` |
| 42 | +```bash |
| 43 | + encode_url |
| 44 | +─────────────── |
| 45 | + Hello%20World |
| 46 | +(1 row) |
| 47 | +``` |
| 48 | +```sql |
| 49 | +SELECT url_tools_schema.decode_url('Hello%20World'); |
| 50 | +``` |
| 51 | +```bash |
| 52 | + decode_url |
| 53 | +───────────── |
| 54 | + Hello World |
| 55 | +(1 row) |
| 56 | +``` |
| 57 | +```sql |
| 58 | +SELECT url_tools_schema.encode_uri('https://ru.wikipedia.org/wiki/Greenplum_(компания)'); |
| 59 | +``` |
| 60 | +```bash |
| 61 | + encode_uri |
| 62 | +──────────────────────────────────────────────────────────────────────────────────────────── |
| 63 | + https://ru.wikipedia.org/wiki/Greenplum_(%D0%BA%D0%BE%D0%BC%D0%BF%D0%B0%D0%BD%D0%B8%D1%8F) |
| 64 | +``` |
| 65 | +```sql |
| 66 | +SELECT url_tools_schema.decode_uri('https://ru.wikipedia.org/wiki/Greenplum_(%D0%BA%D0%BE%D0%BC%D0%BF%D0%B0%D0%BD%D0%B8%D1%8F)'); |
| 67 | +``` |
| 68 | +```bash |
| 69 | + decode_uri |
| 70 | +──────────────────────────────────────────────────── |
| 71 | + https://ru.wikipedia.org/wiki/Greenplum_(компания) |
| 72 | +``` |
| 73 | + |
| 74 | +### Acknowledgments |
| 75 | +Thank you very much for the extension for PostgreSQL: https://github.com/okbob/url_encode, its sources were very useful. |
0 commit comments