OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 #library('url'); |
| 6 #import('node.dart'); |
| 7 |
| 8 // module url |
| 9 |
| 10 class UrlObject { |
| 11 UrlObject._fromObj(var obj) { |
| 12 this.href = _NativeGetStringProperty(obj, 'href'); |
| 13 this.protocol = _NativeGetStringProperty(obj, 'protocol'); |
| 14 this.host = _NativeGetStringProperty(obj, 'host'); |
| 15 this.auth = _NativeGetStringProperty(obj, 'auth'); |
| 16 this.port = _NativeGetStringProperty(obj, 'port'); |
| 17 this.pathname = _NativeGetStringProperty(obj, 'pathname'); |
| 18 this.search = _NativeGetStringProperty(obj, 'search'); |
| 19 this.path = _NativeGetStringProperty(obj, 'path'); |
| 20 this.query = _NativeGetStringProperty(obj, 'query'); |
| 21 this.hash = _NativeGetStringProperty(obj, 'hash'); |
| 22 this.slashes = _NativeGetBoolProperty(obj, 'slashes'); |
| 23 } |
| 24 |
| 25 String href; |
| 26 String protocol; |
| 27 String host; |
| 28 String auth; |
| 29 String hostname; |
| 30 String port; |
| 31 String pathname; |
| 32 String search; |
| 33 String path; |
| 34 String query; |
| 35 String hash; |
| 36 bool slashes; |
| 37 } |
| 38 |
| 39 class Url { |
| 40 var _url; |
| 41 Url._from(this._url); |
| 42 |
| 43 UrlObject parse(String urlStr, [bool parseQueryString, bool slashesDenoteHost] |
| 44 ) |
| 45 => new UrlObject._fromObj(_parse(urlStr, parseQueryString, slashesDenoteHost |
| 46 )); |
| 47 |
| 48 var _parse(String urlStr, bool parseQueryString, bool slashesDenoteHost) |
| 49 native |
| 50 "return this._url.parse(urlStr, parseQueryString, slashesDenoteHost);"; |
| 51 |
| 52 String format(UrlObject urlObj) |
| 53 native "return this._url.format(urlObj);"; |
| 54 |
| 55 String resolve(String from, String to) |
| 56 native "return this._url.resolve(from, to);"; |
| 57 |
| 58 UrlObject resolveObject(UrlObject from, UrlObject to) |
| 59 => new UrlObject._fromObj(_resolveObject(from, to)); |
| 60 |
| 61 var _resolveObject(UrlObject from, UrlObject to) |
| 62 native "return this._url.resolveOjbect(from, to);"; |
| 63 } |
| 64 |
| 65 Url get url() => new Url._from(require('url')); |
OLD | NEW |