+2004-10-03 Helge Hess <helge.hess@opengroupware.org>
+
+ * DynamicElements/_WOComplexHyperlink.m: minor code cleanups (v4.3.51)
+
2004-09-30 Helge Hess <helge.hess@skyrix.com>
* WOHttpAdaptor/WOHttpAdaptor.m: print listen address as a string value
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
#include "WOHyperlink.h"
/* URI generation */
+- (BOOL)shouldRewriteURLString:(NSString *)_s inContext:(WOContext *)_ctx {
+ // TODO: we need a binding to disable rewriting!
+ if ([_s hasPrefix:@"mailto:"])
+ return NO;
+ if ([_s hasPrefix:@"javascript:"])
+ return NO;
+ return YES;
+}
+
- (BOOL)_appendHrefToResponse:(WOResponse *)_r inContext:(WOContext *)_ctx {
NSString *s;
id hrefValue;
if (hrefValue == nil)
return NO;
-
+
if ([hrefValue isKindOfClass:NSURLClass]) {
s = [hrefValue stringValueRelativeToURL:base];
}
else {
s = [hrefValue stringValue];
- if (!([s hasPrefix:@"mailto:"] || [s hasPrefix:@"javascript:"])) {
+ if ([self shouldRewriteURLString:s inContext:_ctx]) {
if ([s isAbsoluteURL]) {
// TODO: why are we doing this? we could just pass through the string?
// => probably to generate relative links
url = [NSURLClass URLWithString:s];
}
else if (base != nil) {
- url = [NSURLClass URLWithString:s relativeToURL:base];
+ /* avoid creating a new URL for ".", just return the base */
+ url = [s isEqualToString:@"."]
+ ? base
+ : [NSURLClass URLWithString:s relativeToURL:base];
}
else {
[self logWithFormat:@"WARNING: missing base URL in context ..."];
s, base];
return NO;
}
+
s = [url stringValueRelativeToURL:base];
}
}