Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Unified Diff: frog/lib/node/url.dart

Issue 9034014: Add support for the node net module. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: frog/lib/node/url.dart
===================================================================
--- frog/lib/node/url.dart (revision 0)
+++ frog/lib/node/url.dart (revision 0)
@@ -0,0 +1,65 @@
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+#library('url');
+#import('node.dart');
+
+// module url
+
+class UrlObject {
+ UrlObject._fromObj(var obj) {
+ this.href = _NativeGetStringProperty(obj, 'href');
+ this.protocol = _NativeGetStringProperty(obj, 'protocol');
+ this.host = _NativeGetStringProperty(obj, 'host');
+ this.auth = _NativeGetStringProperty(obj, 'auth');
+ this.port = _NativeGetStringProperty(obj, 'port');
+ this.pathname = _NativeGetStringProperty(obj, 'pathname');
+ this.search = _NativeGetStringProperty(obj, 'search');
+ this.path = _NativeGetStringProperty(obj, 'path');
+ this.query = _NativeGetStringProperty(obj, 'query');
+ this.hash = _NativeGetStringProperty(obj, 'hash');
+ this.slashes = _NativeGetBoolProperty(obj, 'slashes');
+ }
+
+ String href;
+ String protocol;
+ String host;
+ String auth;
+ String hostname;
+ String port;
+ String pathname;
+ String search;
+ String path;
+ String query;
+ String hash;
+ bool slashes;
+}
+
+class Url {
+ var _url;
+ Url._from(this._url);
+
+ UrlObject parse(String urlStr, [bool parseQueryString, bool slashesDenoteHost]
+ )
+ => new UrlObject._fromObj(_parse(urlStr, parseQueryString, slashesDenoteHost
+ ));
+
+ var _parse(String urlStr, bool parseQueryString, bool slashesDenoteHost)
+ native
+ "return this._url.parse(urlStr, parseQueryString, slashesDenoteHost);";
+
+ String format(UrlObject urlObj)
+ native "return this._url.format(urlObj);";
+
+ String resolve(String from, String to)
+ native "return this._url.resolve(from, to);";
+
+ UrlObject resolveObject(UrlObject from, UrlObject to)
+ => new UrlObject._fromObj(_resolveObject(from, to));
+
+ var _resolveObject(UrlObject from, UrlObject to)
+ native "return this._url.resolveOjbect(from, to);";
+}
+
+Url get url() => new Url._from(require('url'));

Powered by Google App Engine
This is Rietveld 408576698