blob: dfa057fd09c3b13cdc8ee4c4312d938086274d63 [file] [log] [blame]
Ben Murdochc5610432016-08-08 18:44:38 +01001// 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
11namespace v8 {
12namespace internal {
13
14class Uri : public AllStatic {
15 public:
Ben Murdoch61f157c2016-09-16 13:49:30 +010016 // 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 Murdochc5610432016-08-08 18:44:38 +010029 return Encode(isolate, uri, true);
30 }
31
Ben Murdoch61f157c2016-09-16 13:49:30 +010032 // ES6 section 18.2.6.5 encodeURIComponenet (uriComponent)
33 static MaybeHandle<String> EncodeUriComponent(Isolate* isolate,
34 Handle<String> component) {
Ben Murdochc5610432016-08-08 18:44:38 +010035 return Encode(isolate, component, false);
36 }
37
Ben Murdoch61f157c2016-09-16 13:49:30 +010038 // 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 Murdochc5610432016-08-08 18:44:38 +010043
44 private:
Ben Murdoch61f157c2016-09-16 13:49:30 +010045 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 Murdochc5610432016-08-08 18:44:38 +010049};
50
51} // namespace internal
52} // namespace v8
53
54#endif // V8_URI_H_