<commit_before>import { UrlContext } from './UrlContext';
import { NotImplementedError } from './errors/NotImplementedError';

export class Component {
	constructor(routeUrl) {
		this.routeParts = Component.parseRoute(routeUrl);
	}

	onUrlChanged(url) {
		if (url.substr(0, 5) === 'http:' ||
			url.substr(0, 6) === 'https:') {

			const loc = url.indexOf('/', 8);
			url = url.substr(loc);
		}
		const urlParams = this.routeParts.matchUrlAndGetParams(url);
		if (urlParams) {
			const ctxt = new UrlContext(url, urlParams);
			this.render(ctxt);
		}
	}

	// ctxt: instance of UrlContext
	render(ctxt) {
		throw new NotImplementedError('render method not yet implemented');
	}

	// Helper method that extracts the route parts from a route url
	// Example routeUrl:
	//	/person
	//	/person/:id
	//	/person/:id/address
	static parseRoute(routeUrl) {
		let piecesArr = [];
		routeUrl.split('/').forEach(piece => {<commit_msg>Added console writing for Component.render errors<commit_after>import { UrlContext } from './UrlContext';
import { NotImplementedError } from './errors/NotImplementedError';

export class Component {
	constructor(routeUrl) {
		this.routeParts = Component.parseRoute(routeUrl);
	}

	onUrlChanged(url) {
		if (url.substr(0, 5) === 'http:' ||
			url.substr(0, 6) === 'https:') {

			const loc = url.indexOf('/', 8);
			url = url.substr(loc);
		}
		const urlParams = this.routeParts.matchUrlAndGetParams(url);
		if (urlParams) {
			const ctxt = new UrlContext(url, urlParams);
			try {
				this.render(ctxt);
			} catch (e) {
				console.error(e);
			}
		}
	}

	// ctxt: instance of UrlContext
	render(ctxt) {
		throw new NotImplementedError('render method not yet implemented');
	}

	// Helper method that extracts the route parts from a route url
	// Example routeUrl:
	//	/person
	//	/person/:id
	//	/person/:id/address
	static parseRoute(routeUrl) {
		let piecesArr = [];
		routeUrl.split('/').forEach(piece => {
{'fraction_non_alphanumeric': 0.1514994829369183, 'fraction_numerical': 0.005170630816959669, 'mean_word_length': 3.6739130434782608, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3464265', 'n_tokens_mistral': 703, 'n_tokens_neox': 646, 'n_words': 153}