mirror of
				https://github.com/Jermolene/TiddlyWiki5
				synced 2025-10-31 07:32:59 +00:00 
			
		
		
		
	Fix problem with parsing text references
This commit is contained in:
		| @@ -461,7 +461,7 @@ Returns an object with the following fields, all optional: | |||||||
| */ | */ | ||||||
| exports.parseTextReference = function(textRef) { | exports.parseTextReference = function(textRef) { | ||||||
| 	// Separate out the title, field name and/or JSON indices | 	// Separate out the title, field name and/or JSON indices | ||||||
| 	var reTextRef = /^\s*([^!#]+)?(?:(?:!!([^\s]+))|(?:##(.+)))?\s*/mg, | 	var reTextRef = /(?:(.*?)!!(.+))|(?:(.*?)##(.+))|(.*)/mg, | ||||||
| 		match = reTextRef.exec(textRef), | 		match = reTextRef.exec(textRef), | ||||||
| 		result = {}; | 		result = {}; | ||||||
| 	if(match && reTextRef.lastIndex === textRef.length) { | 	if(match && reTextRef.lastIndex === textRef.length) { | ||||||
| @@ -473,7 +473,13 @@ exports.parseTextReference = function(textRef) { | |||||||
| 			result.field = match[2]; | 			result.field = match[2]; | ||||||
| 		} | 		} | ||||||
| 		if(match[3]) { | 		if(match[3]) { | ||||||
| 			result.index = match[3]; | 			result.title = match[3]; | ||||||
|  | 		} | ||||||
|  | 		if(match[4]) { | ||||||
|  | 			result.index = match[4]; | ||||||
|  | 		} | ||||||
|  | 		if(match[5]) { | ||||||
|  | 			result.title = match[5]; | ||||||
| 		} | 		} | ||||||
| 	} else { | 	} else { | ||||||
| 		// If we couldn't parse it | 		// If we couldn't parse it | ||||||
|   | |||||||
| @@ -39,8 +39,11 @@ describe("Utility tests", function() { | |||||||
| 		expect(ptr("ti#tle##index")).toEqual( | 		expect(ptr("ti#tle##index")).toEqual( | ||||||
| 			{ title : 'ti#tle', index : 'index' } | 			{ title : 'ti#tle', index : 'index' } | ||||||
| 		); | 		); | ||||||
|  | 		expect(ptr("ti!tle!!field")).toEqual( | ||||||
|  | 			{ title : 'ti!tle', field : 'field' } | ||||||
|  | 		); | ||||||
| 		expect(ptr("title##index!!field")).toEqual( | 		expect(ptr("title##index!!field")).toEqual( | ||||||
| 			{ title : 'title', index : 'index!!field' } | 			{ title : 'title##index', field : 'field' } | ||||||
| 		); | 		); | ||||||
| 		expect(ptr("title!!field##index")).toEqual( | 		expect(ptr("title!!field##index")).toEqual( | ||||||
| 			{ title : 'title', field : 'field##index' } | 			{ title : 'title', field : 'field##index' } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Jermolene
					Jermolene