mirror of
https://github.com/orangecoding/fredy.git
synced 2026-06-16 12:31:07 +00:00
fixing new immoscout url handling
This commit is contained in:
@@ -159,10 +159,10 @@ export function convertWebToMobile(webUrl) {
|
|||||||
const { query: webParams } = queryString.parseUrl(webUrl, { arrayFormat: 'comma' });
|
const { query: webParams } = queryString.parseUrl(webUrl, { arrayFormat: 'comma' });
|
||||||
delete webParams['enteredFrom'];
|
delete webParams['enteredFrom'];
|
||||||
|
|
||||||
// Check for unsupported parameters
|
// Remove unsupported parameters
|
||||||
Object.keys(webParams).forEach((key) => {
|
Object.keys(webParams).forEach((key) => {
|
||||||
if (!paramNameMap[key]) {
|
if (!paramNameMap[key]) {
|
||||||
throw new Error(`Unsupported Web-API parameter: "${key}"`);
|
delete webParams[key];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -52,10 +52,10 @@ describe('#immoscout-mobile URL conversion', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Test URL conversion with unsupported query parameters
|
// Test URL conversion with unsupported query parameters
|
||||||
it('should throw an error for unsupported query parameters', () => {
|
it('should remove unsupported query parameters', () => {
|
||||||
const webUrl = 'https://www.immobilienscout24.de/Suche/de/berlin/berlin/wohnung-mieten?minimuminternetspeed=100000';
|
const webUrl = 'https://www.immobilienscout24.de/Suche/de/berlin/berlin/wohnung-mieten?minimuminternetspeed=100000';
|
||||||
|
const converted = convertWebToMobile(webUrl);
|
||||||
expect(() => convertWebToMobile(webUrl)).to.throw('Unsupported Web-API parameter: "minimuminternetspeed"');
|
expect(converted).that.does.not.include('minimuminternetspeed');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Test URL conversion with invalid URL
|
// Test URL conversion with invalid URL
|
||||||
@@ -68,7 +68,6 @@ describe('#immoscout-mobile URL conversion', () => {
|
|||||||
// Test URL conversion with unexpected path format
|
// Test URL conversion with unexpected path format
|
||||||
it('should throw an error for unexpected path format', () => {
|
it('should throw an error for unexpected path format', () => {
|
||||||
const webUrl = 'https://www.immobilienscout24.de/invalid/path/format';
|
const webUrl = 'https://www.immobilienscout24.de/invalid/path/format';
|
||||||
|
|
||||||
expect(() => convertWebToMobile(webUrl)).to.throw('Unexpected path format: /invalid/path/format');
|
expect(() => convertWebToMobile(webUrl)).to.throw('Unexpected path format: /invalid/path/format');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user