Trim leading/trailing whitespace. Closes #175
This commit is contained in:
		| @@ -82,6 +82,6 @@ export class DirectiveParser implements ParserInterface { | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	protected cleanKey(val: string): string { | 	protected cleanKey(val: string): string { | ||||||
| 		return val.replace(/\r?\n|\r|\t/g, ''); | 		return val.replace(/\r?\n|\r|\t/g, '').trim(); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|   | |||||||
| @@ -117,4 +117,22 @@ describe('DirectiveParser', () => { | |||||||
| 		const keys = parser.extract(contents, templateFilename).keys(); | 		const keys = parser.extract(contents, templateFilename).keys(); | ||||||
| 		expect(keys).to.deep.equal(['client.search.searchBtn']); | 		expect(keys).to.deep.equal(['client.search.searchBtn']); | ||||||
| 	}); | 	}); | ||||||
|  |  | ||||||
|  | 	it('should extract contents without indent spaces and trim leading/trailing whitespace', () => { | ||||||
|  | 		const contents = ` | ||||||
|  | 			<div translate> | ||||||
|  | 				this is an example  | ||||||
|  | 				of a long label  | ||||||
|  | 			</div> | ||||||
|  |  | ||||||
|  | 			<div> | ||||||
|  | 				<p translate> | ||||||
|  | 					this is an example  | ||||||
|  | 					of a long label  | ||||||
|  | 				</p> | ||||||
|  | 			</div> | ||||||
|  | 		`; | ||||||
|  | 		const keys = parser.extract(contents, templateFilename).keys(); | ||||||
|  | 		expect(keys).to.deep.equal(['this is an example of a long label']); | ||||||
|  | 	}); | ||||||
| }); | }); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user