uri.h 1.79 KB
Newer Older
1 2 3 4
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6
#ifndef V8_STRINGS_URI_H_
#define V8_STRINGS_URI_H_
7

8
#include "src/utils/allocation.h"
9
#include "src/handles/maybe-handles.h"
10
#include "src/objects/objects.h"
11 12 13 14 15 16

namespace v8 {
namespace internal {

class Uri : public AllStatic {
 public:
17 18 19 20 21 22 23 24 25 26 27 28
  // ES6 section 18.2.6.2 decodeURI (encodedURI)
  static MaybeHandle<String> DecodeUri(Isolate* isolate, Handle<String> uri) {
    return Decode(isolate, uri, true);
  }

  // ES6 section 18.2.6.3 decodeURIComponent (encodedURIComponent)
  static MaybeHandle<String> DecodeUriComponent(Isolate* isolate,
                                                Handle<String> component) {
    return Decode(isolate, component, false);
  }

  // ES6 section 18.2.6.4 encodeURI (uri)
29
  static MaybeHandle<String> EncodeUri(Isolate* isolate, Handle<String> uri) {
30 31 32
    return Encode(isolate, uri, true);
  }

33
  // ES6 section 18.2.6.5 encodeURIComponenet (uriComponent)
34 35
  static MaybeHandle<String> EncodeUriComponent(Isolate* isolate,
                                                Handle<String> component) {
36 37 38
    return Encode(isolate, component, false);
  }

39 40 41 42 43 44
  // ES6 section B.2.1.1 escape (string)
  static MaybeHandle<String> Escape(Isolate* isolate, Handle<String> string);

  // ES6 section B.2.1.2 unescape (string)
  static MaybeHandle<String> Unescape(Isolate* isolate, Handle<String> string);

45
 private:
46 47
  static MaybeHandle<String> Decode(Isolate* isolate, Handle<String> uri,
                                    bool is_uri);
48 49
  static MaybeHandle<String> Encode(Isolate* isolate, Handle<String> uri,
                                    bool is_uri);
50 51 52 53 54
};

}  // namespace internal
}  // namespace v8

55
#endif  // V8_STRINGS_URI_H_