const isDev = window.location.port == 3007;
export const TEST_HOST = "https://pre-newweb.educoder.net"
export function getImageUrl(path) {
	// https://www.educoder.net
	// https://testbdweb.trustie.net
  // const local = 'http://localhost:3000'
  const local = 'https://pre-newweb.educoder.net'
	if (isDev) {
		return `${local}/${path}`
	}
	return `/${path}`;
}

export function setImagesUrl(path){
	const local = 'https://pre-newweb.educoder.net'
	let firstStr=path.substr(0,1);
	// console.log(firstStr);
	if(firstStr=="/"){
		return isDev?`${local}${path}`:`${path}`;
	}else{
		return isDev?`${local}/${path}`:`/${path}`;
	}
}

export function getUrl(path, goTest) {
	// https://www.educoder.net
	// https://testbdweb.trustie.net

	// 如果想所有url定位到测试版，可以反注释掉下面这行
	//goTest = true
	// testbdweb.educoder.net testbdweb.trustie.net
  // const local = goTest ? 'https://testeduplus2.educoder.net' : 'http://localhost:3000'
  // const local = 'https://testeduplus2.educoder.net'
	const local = 'https://pre-newweb.educoder.net'
	if (isDev) {
		return `${local}${path?path:''}`
	}
	return `${path ? path: ''}`;
}
export function getUrl2(path, goTest) {
  	const local = 'http://localhost:3000'
	if (isDev) {
		return `${local}${path?path:''}`
	}
	return `${path ? path: ''}`;
}
export function getUploadActionUrl(path, goTest) {
	return `${getUrl()}/api/attachments.json${isDev ? `?debug=${window._debugType || 'admin'}` : ''}`
}
export function getUploadActionUrlOfAuth(id) {
	return `${getUrl()}/api/users/accounts/${id}/auth_attachments.json${isDev ? `?debug=${window._debugType || 'admin'}` : ''}`
}

export function test(path) {
	return `${path}`;
}

export function toPath(path) {
	window.open(path, '_blank');
}


export function getTaskUrlById(id) {
	return `/tasks/${id}`
}
