@autobusal/routes-search 1.3.2 → 1.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.3.3 (2026-08-29)
4
+
5
+ - A city with a single station lists that station instead of an identical "All Stations" entry beside it; the submitted value stays the city's slug, so URLs are unchanged.
6
+
3
7
  ## 1.2.0
4
8
 
5
9
  **The date picker follows the departure city.** Choosing a "from" city now sets the picker's floor to that city's timezone, and a pre-filled form (a shared link, or the search form kept on the results page) sets it on mount rather than waiting for a keystroke.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autobusal/routes-search",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
4
4
  "author": "Ferjolt Ozuni",
5
5
  "type": "module",
6
6
  "main": "index.ts"
package/utilities.ts CHANGED
@@ -27,13 +27,41 @@ export const getCities = (cities: CityData[], t: TFunction<'common'>): Autocompl
27
27
  city.slug
28
28
  ].filter(Boolean);
29
29
 
30
+ const stops = city.stops ?? [];
31
+
32
+ /*
33
+ * Edited: Claude - Date: 2026-08-29
34
+ *
35
+ * A CITY WITH ONE STATION OFFERS NO CHOICE. Listing both "(All
36
+ * Stations)" and the station itself puts two entries in the box for
37
+ * one place, and the visitor has to read both to discover they are the
38
+ * same - so the station is named and the pair collapses to a single
39
+ * line.
40
+ *
41
+ * The value stays the CITY's, not the station's: with one station the
42
+ * search is identical either way, and keeping the city slug keeps the
43
+ * URL (and everything keyed off it - canonicals, the prerendered pair
44
+ * pages, the date strip) exactly as it is. The day a second station
45
+ * appears, this reverts to "All Stations" plus one entry each, on its
46
+ * own.
47
+ */
48
+ if (stops.length === 1) {
49
+ data.push({
50
+ name: `${ city.name }, ${ city.country?.name ?? '' } (${ stops[0].name })`,
51
+ value: `${ city.slug }`,
52
+ search: [ ...search, stops[0].name ]
53
+ });
54
+
55
+ return;
56
+ }
57
+
30
58
  data.push({
31
59
  name: `${ city.name }, ${ city.country?.name ?? '' } (${ t('all_stations', { ns: 'common' }) })`,
32
60
  value: `${ city.slug }`,
33
61
  search
34
62
  });
35
63
 
36
- city.stops?.forEach(stop => {
64
+ stops.forEach(stop => {
37
65
  data.push({
38
66
  name: `${ city.name }, ${ city.country?.name ?? '' } (${ stop.name })`,
39
67
  value: `${ city.slug }:${ stop.id }`,