Skip to content

Commit 1926050

Browse files
authored
Bump query-string and enable transpilation of it (#3071)
* Bump query-string and enable transpilation of it query-string was previously frozen to v5 because it broke on Safari 9. See #1053 We should just transpile it ourselves to support our browser matrix. * Replace transpilation regex to path.join to follow Webpack best practices * Further bump query-string 6.13.7 -> 6.13.8 and re-remove @types/query-string added in bad merge * Fix type errors
1 parent 3adc24d commit 1926050

File tree

7 files changed

+37
-31
lines changed

7 files changed

+37
-31
lines changed

renovate.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,7 @@
6565
"groupName": "definitelyTyped"
6666
}
6767
],
68-
"ignoreDeps": [
69-
"query-string",
70-
"@types/query-string",
71-
"@material/snackbar",
72-
"@material/fab",
73-
"puppeteer",
74-
"searchkit"
75-
],
68+
"ignoreDeps": ["@material/snackbar", "@material/fab", "puppeteer", "searchkit"],
7669
"pathRules": [
7770
{
7871
"paths": ["packages/**"],

website/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"@types/leaflet": "1.5.21",
4949
"@types/lodash": "4.14.167",
5050
"@types/mousetrap": "1.6.5",
51-
"@types/query-string": "5.0.0",
51+
"@types/no-scroll": "2.1.0",
5252
"@types/react": "17.0.0",
5353
"@types/react-beautiful-dnd": "13.0.0",
5454
"@types/react-dom": "17.0.0",
@@ -144,7 +144,7 @@
144144
"lodash": "4.17.20",
145145
"mousetrap": "1.6.5",
146146
"nusmoderator": "3.0.0",
147-
"query-string": "5.0.0",
147+
"query-string": "6.13.8",
148148
"react": "17.0.1",
149149
"react-beautiful-dnd": "13.0.0",
150150
"react-dom": "17.0.1",

website/src/utils/debug.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ export function forceElasticsearchHost() {
2121
// Force the current date/time to some value for components that use the
2222
// global timer HOC
2323
export function forceTimer() {
24-
const dateString = getParams().date;
24+
let dateString = getParams().date;
2525
if (!dateString) return null;
26+
if (Array.isArray(dateString)) [dateString] = dateString;
2627

2728
const date = new Date(dateString);
2829
if (Number.isNaN(date.getTime())) return null;

website/src/utils/timetables.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ export function serializeTimetable(timetable: SemTimetableConfig): string {
444444
}
445445

446446
export function deserializeTimetable(serialized: string): SemTimetableConfig {
447-
const params: Record<string, string> = qs.parse(serialized);
447+
const params = qs.parse(serialized);
448448
return mapValues(params, parseModuleConfig);
449449
}
450450

website/src/views/venues/VenuesContainer.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,16 @@ export class VenuesContainerComponent extends Component<Props, State> {
7272
// Extract searchOptions from the query string if they are present
7373
const isAvailabilityEnabled = !!(params.time && params.day && params.duration);
7474
const searchOptions = isAvailabilityEnabled
75-
? (mapValues(pick(params, ['time', 'day', 'duration']), (i) =>
76-
parseInt(i, 10),
77-
) as VenueSearchOptions)
75+
? (mapValues(pick(params, ['time', 'day', 'duration']), (i) => {
76+
if (!i) return NaN;
77+
if (Array.isArray(i)) return parseInt(i[0], 10);
78+
return parseInt(i, 10);
79+
}) as VenueSearchOptions)
7880
: defaultSearchOptions();
7981

8082
this.history = new HistoryDebouncer(history);
81-
const searchTerm = params.q || '';
83+
let searchTerm = params.q || '';
84+
if (Array.isArray(searchTerm)) [searchTerm] = searchTerm;
8285
this.state = {
8386
searchOptions,
8487
isAvailabilityEnabled,

website/webpack/webpack.config.common.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ const commonConfig = {
6363
// TODO: Remove after we drop support for iOS <= 11.2 and Microsoft Edge 18.
6464
path.join(parts.PATHS.root, parts.PATHS.node, 'react-leaflet'),
6565
path.join(parts.PATHS.root, parts.PATHS.node, '@react-leaflet'),
66+
// query-string has had a history of dropping support for browsers, so
67+
// we cannot assume that it supports our browser support matrix.
68+
// See: https://github.com/nusmodifications/nusmods/pull/1053
69+
path.join(parts.PATHS.root, parts.PATHS.node, 'query-string'),
6670
],
6771
use: ['babel-loader'],
6872
},

website/yarn.lock

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,6 +1794,11 @@
17941794
resolved "https://registry.yarnpkg.com/@types/mousetrap/-/mousetrap-1.6.5.tgz#e95569aa6273dbe0ed1814f86287547cc06e93c9"
17951795
integrity sha512-OwVhKFim9Y/MprzCe4I6a59p31pMy8+LrtP6qS7J0kaOxYmW6VVJPBw5NYm+g7nSbgPUz22FvqU1F1hC5YGTfg==
17961796

1797+
1798+
version "2.1.0"
1799+
resolved "https://registry.yarnpkg.com/@types/no-scroll/-/no-scroll-2.1.0.tgz#d50280440fe1bc85c7481f40e35dc51be7b54bb8"
1800+
integrity sha512-67oe0I3SZeEsCIcf5MT4yKrcJOIZn5g+ytPEn+JQQnM4IprztFAWg9T3ngVGbxkceJlLYBsqIfvHl9xEGTuPyA==
1801+
17971802
"@types/node@*":
17981803
version "14.14.14"
17991804
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.14.tgz#f7fd5f3cc8521301119f63910f0fb965c7d761ae"
@@ -1824,11 +1829,6 @@
18241829
resolved "https://registry.yarnpkg.com/@types/q/-/q-1.5.4.tgz#15925414e0ad2cd765bfef58842f7e26a7accb24"
18251830
integrity sha512-1HcDas8SEj4z1Wc696tH56G8OlRaH/sqZOynNNB+HF0WOeXPaxTtbYzJY2oEfiUxjSKjhCKr+MvR7dCHcEelug==
18261831

1827-
1828-
version "5.0.0"
1829-
resolved "https://registry.yarnpkg.com/@types/query-string/-/query-string-5.0.0.tgz#5dbebd24d0abeb555d0dd9704c33462d84a45e69"
1830-
integrity sha512-5wxncaH2wdueIw8mYrRF+G+1sxwxK9AQYWK6V+EJvZ52YesFh2PnG7yRQ4zeThd2Ewy6xCCTUCG6tfRyUzqyIA==
1831-
18321832
18331833
version "13.0.0"
18341834
resolved "https://registry.yarnpkg.com/@types/react-beautiful-dnd/-/react-beautiful-dnd-13.0.0.tgz#e60d3d965312fcf1516894af92dc3e9249587db4"
@@ -9682,14 +9682,14 @@ qs@~6.5.2:
96829682
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36"
96839683
integrity sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==
96849684

9685-
query-string@5.0.0:
9686-
version "5.0.0"
9687-
resolved "https://registry.yarnpkg.com/query-string/-/query-string-5.0.0.tgz#fbdf7004b4d2aff792f9871981b7a2794f555947"
9688-
integrity sha1-+99wBLTSr/eS+YcZgbeieU9VWUc=
9685+
query-string@6.13.8:
9686+
version "6.13.8"
9687+
resolved "https://registry.yarnpkg.com/query-string/-/query-string-6.13.8.tgz#8cf231759c85484da3cf05a851810d8e825c1159"
9688+
integrity sha512-jxJzQI2edQPE/NPUOusNjO/ZOGqr1o2OBa/3M00fU76FsLXDVbJDv/p7ng5OdQyorKrkRz1oqfwmbe5MAMePQg==
96899689
dependencies:
96909690
decode-uri-component "^0.2.0"
9691-
object-assign "^4.1.0"
9692-
strict-uri-encode "^1.0.0"
9691+
split-on-first "^1.0.0"
9692+
strict-uri-encode "^2.0.0"
96939693

96949694
querystring-es3@^0.2.0:
96959695
version "0.2.1"
@@ -11090,6 +11090,11 @@ specificity@^0.4.1:
1109011090
resolved "https://registry.yarnpkg.com/specificity/-/specificity-0.4.1.tgz#aab5e645012db08ba182e151165738d00887b019"
1109111091
integrity sha512-1klA3Gi5PD1Wv9Q0wUoOQN1IWAuPu0D1U03ThXTr0cJ20+/iq2tHSDnK7Kk/0LXJ1ztUB2/1Os0wKmfyNgUQfg==
1109211092

11093+
split-on-first@^1.0.0:
11094+
version "1.1.0"
11095+
resolved "https://registry.yarnpkg.com/split-on-first/-/split-on-first-1.1.0.tgz#f610afeee3b12bce1d0c30425e76398b78249a5f"
11096+
integrity sha512-43ZssAJaMusuKWL8sKUBQXHWOpq8d6CfN/u1p4gUzfJkM05C8rxTmYrkIPTXapZpORA6LkkzcUulJ8FqA7Uudw==
11097+
1109311098
split-string@^3.0.1, split-string@^3.0.2:
1109411099
version "3.1.0"
1109511100
resolved "https://registry.yarnpkg.com/split-string/-/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2"
@@ -11185,10 +11190,10 @@ stream-http@^2.7.2:
1118511190
to-arraybuffer "^1.0.0"
1118611191
xtend "^4.0.0"
1118711192

11188-
strict-uri-encode@^1.0.0:
11189-
version "1.1.0"
11190-
resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz#279b225df1d582b1f54e65addd4352e18faa0713"
11191-
integrity sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM=
11193+
strict-uri-encode@^2.0.0:
11194+
version "2.0.0"
11195+
resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz#b9c7330c7042862f6b142dc274bbcc5866ce3546"
11196+
integrity sha1-ucczDHBChi9rFC3CdLvMWGbONUY=
1119211197

1119311198
string-convert@^0.2.0:
1119411199
version "0.2.1"

0 commit comments

Comments
 (0)