You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					20 lines
				
				628 B
			
		
		
			
		
	
	
					20 lines
				
				628 B
			| 
								 
											4 years ago
										 
									 | 
							
								const beautify = require('pretty')
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								const isHtmlString = received => received && typeof received === 'string' && received[0] === '<'
							 | 
						||
| 
								 | 
							
								const isVueWrapper = received => (
							 | 
						||
| 
								 | 
							
								  received &&
							 | 
						||
| 
								 | 
							
								  typeof received === 'object' &&
							 | 
						||
| 
								 | 
							
								  typeof received.isVueInstance === 'function'
							 | 
						||
| 
								 | 
							
								)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								module.exports = {
							 | 
						||
| 
								 | 
							
								  test (received) {
							 | 
						||
| 
								 | 
							
								    return isHtmlString(received) || isVueWrapper(received)
							 | 
						||
| 
								 | 
							
								  },
							 | 
						||
| 
								 | 
							
								  print (received) {
							 | 
						||
| 
								 | 
							
								    const html = (isVueWrapper(received) ? received.html() : received) || ''
							 | 
						||
| 
								 | 
							
								    const removedServerRenderedText = html.replace(/ data-server-rendered="true"/, '')
							 | 
						||
| 
								 | 
							
								    return beautify(removedServerRenderedText, { indent_size: 2 })
							 | 
						||
| 
								 | 
							
								  }
							 | 
						||
| 
								 | 
							
								}
							 |