mirror of
https://github.com/orangecoding/fredy.git
synced 2026-06-16 12:31:07 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2f00966f27 | ||
|
|
921057252d |
@@ -168,10 +168,6 @@ export function convertWebToMobile(webUrl) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (segments.includes('shape')) {
|
|
||||||
throw new Error('Shape is currently not supported using Immoscout');
|
|
||||||
}
|
|
||||||
|
|
||||||
const { query: rawParams } = queryString.parseUrl(webUrl, { arrayFormat: 'comma' });
|
const { query: rawParams } = queryString.parseUrl(webUrl, { arrayFormat: 'comma' });
|
||||||
const webParams = Object.fromEntries(
|
const webParams = Object.fromEntries(
|
||||||
Object.entries(rawParams).filter(([key]) => key !== 'enteredFrom' && PARAM_NAME_MAP[key]),
|
Object.entries(rawParams).filter(([key]) => key !== 'enteredFrom' && PARAM_NAME_MAP[key]),
|
||||||
@@ -179,18 +175,31 @@ export function convertWebToMobile(webUrl) {
|
|||||||
|
|
||||||
const geocodes = `/${segments.slice(2, segments.length - 1).join('/')}`;
|
const geocodes = `/${segments.slice(2, segments.length - 1).join('/')}`;
|
||||||
const isRadius = segments.includes('radius');
|
const isRadius = segments.includes('radius');
|
||||||
|
const isShape = segments.includes('shape');
|
||||||
const mobileParams = {
|
const mobileParams = {
|
||||||
searchType: isRadius ? 'radius' : 'region',
|
searchType: isRadius ? 'radius' : isShape ? 'shape' : 'region',
|
||||||
realestatetype: realType,
|
realestatetype: realType,
|
||||||
...(isRadius ? {} : { geocodes }),
|
...(isRadius || isShape ? {} : { geocodes }),
|
||||||
...additionalParamsFromWebPath,
|
...additionalParamsFromWebPath,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (isShape && !webParams.shape) {
|
||||||
|
throw new Error('Shape search URL is missing the required "shape" query parameter');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isShape && webParams.shape) {
|
||||||
|
const browserShape = webParams.shape;
|
||||||
|
const normalized = browserShape.replace(/\.\./g, '==').replace(/\./g, '=');
|
||||||
|
const polyline = Buffer.from(normalized, 'base64').toString('utf-8');
|
||||||
|
mobileParams.shape = polyline;
|
||||||
|
}
|
||||||
|
|
||||||
if (webParams.geocoordinates) {
|
if (webParams.geocoordinates) {
|
||||||
mobileParams.geocoordinates = webParams.geocoordinates;
|
mobileParams.geocoordinates = webParams.geocoordinates;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const [key, val] of Object.entries(webParams)) {
|
for (const [key, val] of Object.entries(webParams)) {
|
||||||
|
if (key === 'shape') continue;
|
||||||
if (key === 'equipment') {
|
if (key === 'equipment') {
|
||||||
const items = [].concat(val).flatMap((v) => `${v}`.split(','));
|
const items = [].concat(val).flatMap((v) => `${v}`.split(','));
|
||||||
const currentEquipmentParams = mobileParams[PARAM_NAME_MAP[key]];
|
const currentEquipmentParams = mobileParams[PARAM_NAME_MAP[key]];
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "fredy",
|
"name": "fredy",
|
||||||
"version": "21.3.0",
|
"version": "21.3.1",
|
||||||
"description": "[F]ind [R]eal [E]states [d]amn eas[y].",
|
"description": "[F]ind [R]eal [E]states [d]amn eas[y].",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepare": "husky",
|
"prepare": "husky",
|
||||||
|
|||||||
@@ -10,6 +10,17 @@ import { readFile } from 'fs/promises';
|
|||||||
export const testData = JSON.parse(await readFile(new URL('./testdata.json', import.meta.url)));
|
export const testData = JSON.parse(await readFile(new URL('./testdata.json', import.meta.url)));
|
||||||
|
|
||||||
describe('#immoscout-mobile URL conversion', () => {
|
describe('#immoscout-mobile URL conversion', () => {
|
||||||
|
// Test shape URL conversion
|
||||||
|
it('should convert a full web URL with shape to mobile URL', () => {
|
||||||
|
const webUrl =
|
||||||
|
'https://www.immobilienscout24.de/Suche/shape/haus-kaufen?shape=aW9yfkhfa3htQXJgUGlnYEBmekhte3BAcXNAfWBsQGNyQ2lkUHVvbEB3eX5Ab25WYn5Fa2BLaGRQY29FaGtTfEhme3xBdHBEdHFMamlHbmdRfHhMcmxPeHlWYnpS&price=-600000.0&ground=240.0-&enteredFrom=result_list';
|
||||||
|
const expectedMobileUrl =
|
||||||
|
'https://api.mobile.immobilienscout24.de/search/list?ground=240.0-&price=-600000.0&realestatetype=housebuy&searchType=shape&shape=ior~H_kxmAr%60Pig%60%40fzHm%7Bp%40qs%40%7D%60l%40crCidPuol%40wy~%40onVb~Ek%60KhdPcoEhkS%7CHf%7B%7CAtpDtqLjiGngQ%7CxLrlOxyVbzR';
|
||||||
|
|
||||||
|
const actualMobileUrl = convertWebToMobile(webUrl);
|
||||||
|
expect(actualMobileUrl).toBe(expectedMobileUrl);
|
||||||
|
});
|
||||||
|
|
||||||
// Test URL conversion
|
// Test URL conversion
|
||||||
it('should convert a full web URL to mobile URL', () => {
|
it('should convert a full web URL to mobile URL', () => {
|
||||||
const webUrl =
|
const webUrl =
|
||||||
|
|||||||
@@ -18,5 +18,9 @@
|
|||||||
"rentHouse": {
|
"rentHouse": {
|
||||||
"url": "https://www.immobilienscout24.de/Suche/de/nordrhein-westfalen/duesseldorf/haus-mieten?enteredFrom=one_step_search",
|
"url": "https://www.immobilienscout24.de/Suche/de/nordrhein-westfalen/duesseldorf/haus-mieten?enteredFrom=one_step_search",
|
||||||
"type": "houserent"
|
"type": "houserent"
|
||||||
|
},
|
||||||
|
"buyHouseWithShape": {
|
||||||
|
"url": "https://www.immobilienscout24.de/Suche/shape/haus-kaufen?shape=aW9yfkhfa3htQXJgUGlnYEBmekhte3BAcXNAfWBsQGNyQ2lkUHVvbEB3eX5Ab25WYn5Fa2BLaGRQY29FaGtTfEhme3xBdHBEdHFMamlHbmdRfHhMcmxPeHlWYnpS&price=-600000.0&ground=240.0-&enteredFrom=result_list",
|
||||||
|
"type": "housebuy"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -141,21 +141,6 @@ export default function ProviderMutator({
|
|||||||
</p>
|
</p>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<Banner
|
|
||||||
fullMode={false}
|
|
||||||
type="warning"
|
|
||||||
closeIcon={null}
|
|
||||||
title={<div style={{ fontWeight: 600, fontSize: '14px', lineHeight: '20px' }}>Warning</div>}
|
|
||||||
style={{ marginBottom: '1rem' }}
|
|
||||||
description={
|
|
||||||
<div>
|
|
||||||
<p>
|
|
||||||
Currently, our Immoscout implementation does not support drawing shapes on a map. Use a radius instead.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Select
|
<Select
|
||||||
filter
|
filter
|
||||||
placeholder="Select a provider"
|
placeholder="Select a provider"
|
||||||
|
|||||||
Reference in New Issue
Block a user