OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_URI_H_ | 5 #ifndef V8_URI_H_ |
6 #define V8_URI_H_ | 6 #define V8_URI_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/objects.h" | 9 #include "src/objects.h" |
10 | 10 |
11 namespace v8 { | 11 namespace v8 { |
12 namespace internal { | 12 namespace internal { |
13 | 13 |
14 class Uri : public AllStatic { | 14 class Uri : public AllStatic { |
15 public: | 15 public: |
16 static Object* EncodeUri(Isolate* isolate, Handle<String> uri) { | 16 // ES6 section 18.2.6.4 encodeURI (uri) |
| 17 static MaybeHandle<Object> EncodeUri(Isolate* isolate, Handle<String> uri) { |
17 return Encode(isolate, uri, true); | 18 return Encode(isolate, uri, true); |
18 } | 19 } |
19 | 20 |
20 static Object* EncodeUriComponent(Isolate* isolate, | 21 // ES6 section 18.2.6.5 encodeURIComponenet (uriComponent) |
21 Handle<String> component) { | 22 static MaybeHandle<Object> EncodeUriComponent(Isolate* isolate, |
| 23 Handle<String> component) { |
22 return Encode(isolate, component, false); | 24 return Encode(isolate, component, false); |
23 } | 25 } |
24 | 26 |
25 // DecodeUri | 27 // ES6 section 18.2.6.2 decodeURI (encodedURI) |
26 // DecodeUriComponent | 28 static MaybeHandle<Object> DecodeUri(Isolate* isolate, Handle<String> uri) { |
27 // escape | 29 return Decode(isolate, uri, true); |
28 // unescape | 30 } |
| 31 |
| 32 // ES6 section 18.2.6.3 decodeURIComponent (encodedURIComponent) |
| 33 static MaybeHandle<Object> DecodeUriComponent(Isolate* isolate, |
| 34 Handle<String> component) { |
| 35 return Decode(isolate, component, false); |
| 36 } |
29 | 37 |
30 private: | 38 private: |
31 static Object* Encode(Isolate* isolate, Handle<String> uri, bool is_uri); | 39 static MaybeHandle<Object> Encode(Isolate* isolate, Handle<String> uri, |
32 // decode | 40 bool is_uri); |
| 41 static MaybeHandle<Object> Decode(Isolate* isolate, Handle<String> uri, |
| 42 bool is_uri); |
33 }; | 43 }; |
34 | 44 |
35 } // namespace internal | 45 } // namespace internal |
36 } // namespace v8 | 46 } // namespace v8 |
37 | 47 |
38 #endif // V8_URI_H_ | 48 #endif // V8_URI_H_ |
OLD | NEW |