Skip to content

Commit

Permalink
PKP: fix by using a specific User-Agent 🐛
Browse files Browse the repository at this point in the history
  • Loading branch information
derhuerst committed Feb 13, 2025
1 parent faef854 commit 4751df3
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions p/pkp/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,27 @@ import {parseLocation} from '../../parse/location.js';
const baseProfile = require('./base.json');
import {products} from './products.js';

// https://github.com/public-transport/hafas-client/issues/184#issuecomment-2646119337
const PKP_USER_AGENT = 'Dalvik/2.1.0';

const trimStopName = ({parsed}, l) => {
if (parsed.type === 'stop' || parsed.type === 'station' && parsed.name) {
parsed.name = parsed.name.replace(/(^-|-$)/g, '');
}
return parsed;
};

const transformReqOverrideUserAgent = (ctx, req) => {
req.headers['user-agent'] = PKP_USER_AGENT

Check failure on line 23 in p/pkp/index.js

View workflow job for this annotation

GitHub Actions / lint

Missing semicolon

Check failure on line 23 in p/pkp/index.js

View workflow job for this annotation

GitHub Actions / lint

Missing semicolon
return req

Check failure on line 24 in p/pkp/index.js

View workflow job for this annotation

GitHub Actions / lint

Missing semicolon

Check failure on line 24 in p/pkp/index.js

View workflow job for this annotation

GitHub Actions / lint

Missing semicolon
}

Check failure on line 25 in p/pkp/index.js

View workflow job for this annotation

GitHub Actions / lint

Missing semicolon

Check failure on line 25 in p/pkp/index.js

View workflow job for this annotation

GitHub Actions / lint

Missing semicolon

const profile = {
...baseProfile,
locale: 'pl-PL',
timezone: 'Europe/Warsaw',
randomizeUserAgent: false,
transformReq: transformReqOverrideUserAgent,

products,

Expand Down

0 comments on commit 4751df3

Please sign in to comment.