Clean up sHref handling a bit

* sHref is now always a string
* fixes crasher when sHref is not set

Change-Id: If5756948ac6bc26c2d7c04d970b5aba5331cb8bb
This commit is contained in:
Gabriel Wicke 2012-06-20 00:34:57 +02:00
parent e117f09362
commit 33dc9abb0d
2 changed files with 6 additions and 7 deletions

View file

@ -49,7 +49,7 @@ WikiLinkHandler.prototype.onWikiLink = function ( token, frame, cb ) {
),
content = token.attribs.slice(2);
if ( href !== normalizedHref ) {
obj.dataAttribs.sHref = href;
obj.dataAttribs.sHref = env.tokensToString( href );
}
//console.warn('content: ' + JSON.stringify( content, null, 2 ) );
// XXX: handle trail

View file

@ -241,14 +241,13 @@ WSP._linkHandler = function( state, token ) {
var tail = tokenData.tail;
if ( tail && tail.length ) {
state.dropTail = tail;
target = tokenData.gc ? tokenData.sHref[0] : target.replace( /_/g, ' ' );
target = tokenData.gc ? tokenData.sHref : target.replace( /_/g, ' ' );
} else {
// SSS: Why is sHref an array instead of a string?
var origLinkTgt = tokenData.sHref[0];
var origLinkTgt = tokenData.sHref;
if (origLinkTgt) {
//console.warn( JSON.stringify( tokenData.sHref ) );
// SSS FIXME: Why was resolveTitle wrapping this? Also, why do we require normalizeTitle here?
var normalizedOrigLinkTgt = env.normalizeTitle(env.tokensToString(origLinkTgt));
// Normalize the source target so that we can compare it
// with href.
var normalizedOrigLinkTgt = env.normalizeTitle( env.tokensToString(origLinkTgt) );
if ( normalizedOrigLinkTgt === target ) {
// Non-standard capitalization
target = origLinkTgt;