Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef V8_URI_H_ |
| 6 | #define V8_URI_H_ |
| 7 | |
| 8 | #include "src/allocation.h" |
| 9 | #include "src/objects.h" |
| 10 | |
| 11 | namespace v8 { |
| 12 | namespace internal { |
| 13 | |
| 14 | class Uri : public AllStatic { |
| 15 | public: |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame] | 16 | // ES6 section 18.2.6.2 decodeURI (encodedURI) |
| 17 | static MaybeHandle<String> DecodeUri(Isolate* isolate, Handle<String> uri) { |
| 18 | return Decode(isolate, uri, true); |
| 19 | } |
| 20 | |
| 21 | // ES6 section 18.2.6.3 decodeURIComponent (encodedURIComponent) |
| 22 | static MaybeHandle<String> DecodeUriComponent(Isolate* isolate, |
| 23 | Handle<String> component) { |
| 24 | return Decode(isolate, component, false); |
| 25 | } |
| 26 | |
| 27 | // ES6 section 18.2.6.4 encodeURI (uri) |
| 28 | static MaybeHandle<String> EncodeUri(Isolate* isolate, Handle<String> uri) { |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 29 | return Encode(isolate, uri, true); |
| 30 | } |
| 31 | |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame] | 32 | // ES6 section 18.2.6.5 encodeURIComponenet (uriComponent) |
| 33 | static MaybeHandle<String> EncodeUriComponent(Isolate* isolate, |
| 34 | Handle<String> component) { |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 35 | return Encode(isolate, component, false); |
| 36 | } |
| 37 | |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame] | 38 | // ES6 section B.2.1.1 escape (string) |
| 39 | static MaybeHandle<String> Escape(Isolate* isolate, Handle<String> string); |
| 40 | |
| 41 | // ES6 section B.2.1.2 unescape (string) |
| 42 | static MaybeHandle<String> Unescape(Isolate* isolate, Handle<String> string); |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 43 | |
| 44 | private: |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame] | 45 | static MaybeHandle<String> Decode(Isolate* isolate, Handle<String> uri, |
| 46 | bool is_uri); |
| 47 | static MaybeHandle<String> Encode(Isolate* isolate, Handle<String> uri, |
| 48 | bool is_uri); |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 49 | }; |
| 50 | |
| 51 | } // namespace internal |
| 52 | } // namespace v8 |
| 53 | |
| 54 | #endif // V8_URI_H_ |