-
Notifications
You must be signed in to change notification settings - Fork 39
URIのエンコード・デコード関数を追加 #608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
URIのエンコード・デコード関数を追加 #608
Conversation
Str:encode_uri Str:encode_uri_component Str:decode_uri Str:decode_uri_component
|
|
|
let v = "https://example.com/?q=あ"
<: encode_uri(v) // https://example.com/?q=%E3%81%82
<: encode_uri_component(v) // https%3A%2F%2Fexample.com%2F%3Fq%3D%E3%81%82 |
|
けっこう数がありますし、新しい名前空間(仮: |
|
名前空間を |
|
名前空間と関数名でuriが重複しているのが気になりますね |
|
javascript組み込みの |
|
JavaScriptのユーザーから分かりやすくするには、名前から元の関数名が容易に連想できることが要件です。 また、昨今のcomponentという語は多様な使われ方をしているため、fullとcomponentを対立関係にすることで意味をわかりやすくできると考えています。 |
|
fullだと、URIの全体を渡さないといけないように見えたり、全ての文字をエンコードするようにも見えたりする気がします |
|
|
実例が確認できたので反映しました。 |
What
Uri:にURIをエンコード・デコードする関数を4個追加しました。@であるべきところが#になっているのを修正しました。@Uri:encode_full(uri: str): struri をURIとしてエンコードした文字列を返します。以下の文字はエンコードされません。
A-Z a-z 0-9 - _ . ! ~ * ' ( ) ; , / ? : @ & = + $ #@Uri:encode_component(text: str): strtext をURI構成要素としてエンコードした文字列を返します。以下の文字はエンコードされません。
A-Z a-z 0-9 - _ . ! ~ * ' ( )@Uri:decode_full(encoded_uri: str): strencoded_uri をエンコードされたURIとしてデコードした文字列を返します。
以下の文字に対応するエスケープシーケンスはデコードされません。
; , / ? : @ & = + $ #@Uri:decode_component(encoded_text: str): strencoded_text をエンコードされたURI構成要素としてデコードした文字列を返します。
Why
close #606
Additional info (optional)