윤규리

rebase

<<<<<<< HEAD
const { response } = require('express');
const fetch = require('node-fetch')
......@@ -92,4 +93,18 @@ function getXY(hospitals, addNum) {
// for loop 다 돈 다음에 return하도록 수정해야함 (하실수 있는분?)
}
module.exports = {getAddress, getXY};
\ No newline at end of file
module.exports = {getAddress, getXY};
=======
// 모듈을 읽어 들입니다.
const request = require('request');
// 요청을 위한 상수를 선언합니다: TOKEN은 자신의 것을 입력해주세요.
const TARGET_URL = 'https://notify-api.line.me/api/notify';
const TOKEN = '2lGVtxPmn2VOsRczarnwqvQ6cMFOpCMnk3QHA4Ykd2E';
GET /v2/local/search/address.${FORMAT} HTTP/1.1
Host: dapi.kakao.com
Authorization: KakaoAK ${REST_API_KEY}
curl -X GET "https://dapi.kakao.com/v2/local/search/address.json?analyze_type=similar&page=1&size=10&query=${ask}" \
-H "Authorization: KakaoAK c14234ba46c574c73715276c5644f397"
>>>>>>> bef06db (Init Address.js)
......
......@@ -55,10 +55,34 @@ try {
cert: fs.readFileSync('./rootca.crt' ,'utf8'),
};
<<<<<<< HEAD
HTTPS.createServer(option, app).listen(sslport, () => {
console.log(`[HTTPS] Server is started on port ${sslport}`);
});
} catch (error) {
console.log('[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 않습니다.');
console.log(error);
}
\ No newline at end of file
}
=======
if (question === '테스트') {
const data = {
'version': '2.0',
'template': {
'outputs': [{
'simpleText': {
'text': '테스트'
}
}],
'quickReplies': [{
'label': goMain,
'action': 'message',
'messageText': goMain
}]
}
}
}
res.json(data);
});
app.listen(23023, () => console.log('node on 23023'));
>>>>>>> bef06db (Init Address.js)
......
......@@ -4,7 +4,10 @@
"requires": true,
"packages": {
<<<<<<< HEAD
<<<<<<< HEAD
=======
=======
>>>>>>> bef06db (Init Address.js)
"node_modules/accepts": {
"version": "1.3.8",
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
......@@ -17,6 +20,7 @@
"node": ">= 0.6"
}
},
<<<<<<< HEAD
>>>>>>> main
"node_modules/ajv": {
"version": "6.12.6",
......@@ -35,11 +39,14 @@
},
<<<<<<< HEAD
=======
=======
>>>>>>> bef06db (Init Address.js)
"node_modules/array-flatten": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
"integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg=="
},
<<<<<<< HEAD
>>>>>>> main
"node_modules/asn1": {
"version": "0.2.6",
......@@ -85,6 +92,8 @@
},
<<<<<<< HEAD
=======
=======
>>>>>>> bef06db (Init Address.js)
"node_modules/body-parser": {
"version": "1.20.1",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz",
......@@ -108,6 +117,7 @@
"npm": "1.2.8000 || >= 1.4.16"
}
},
<<<<<<< HEAD
"node_modules/body-parser/node_modules/qs": {
"version": "6.11.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz",
......@@ -122,6 +132,8 @@
"url": "https://github.com/sponsors/ljharb"
}
},
=======
>>>>>>> bef06db (Init Address.js)
"node_modules/bytes": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
......@@ -142,6 +154,7 @@
"url": "https://github.com/sponsors/ljharb"
}
},
<<<<<<< HEAD
>>>>>>> main
"node_modules/caseless": {
"version": "0.12.0",
......@@ -161,6 +174,8 @@
},
<<<<<<< HEAD
=======
=======
>>>>>>> bef06db (Init Address.js)
"node_modules/content-disposition": {
"version": "0.5.4",
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
......@@ -193,6 +208,7 @@
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
"integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ=="
},
<<<<<<< HEAD
>>>>>>> main
"node_modules/core-util-is": {
"version": "1.0.2",
......@@ -212,6 +228,8 @@
},
<<<<<<< HEAD
=======
=======
>>>>>>> bef06db (Init Address.js)
"node_modules/debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
......@@ -220,6 +238,7 @@
"ms": "2.0.0"
}
},
<<<<<<< HEAD
>>>>>>> main
"node_modules/delayed-stream": {
"version": "1.0.0",
......@@ -231,6 +250,8 @@
},
<<<<<<< HEAD
=======
=======
>>>>>>> bef06db (Init Address.js)
"node_modules/depd": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
......@@ -248,6 +269,7 @@
"npm": "1.2.8000 || >= 1.4.16"
}
},
<<<<<<< HEAD
>>>>>>> main
"node_modules/ecc-jsbn": {
"version": "0.1.2",
......@@ -260,6 +282,8 @@
},
<<<<<<< HEAD
=======
=======
>>>>>>> bef06db (Init Address.js)
"node_modules/ee-first": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
......@@ -273,6 +297,7 @@
"node": ">= 0.8"
}
},
<<<<<<< HEAD
"node_modules/encoding": {
"version": "0.1.13",
"resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.13.tgz",
......@@ -292,6 +317,8 @@
"node": ">=0.10.0"
}
},
=======
>>>>>>> bef06db (Init Address.js)
"node_modules/escape-html": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
......@@ -346,6 +373,7 @@
"node": ">= 0.10.0"
}
},
<<<<<<< HEAD
"node_modules/express/node_modules/qs": {
"version": "6.11.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz",
......@@ -386,6 +414,8 @@
},
<<<<<<< HEAD
=======
=======
>>>>>>> bef06db (Init Address.js)
"node_modules/finalhandler": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz",
......@@ -403,6 +433,7 @@
"node": ">= 0.8"
}
},
<<<<<<< HEAD
>>>>>>> main
"node_modules/forever-agent": {
"version": "0.6.1",
......@@ -427,6 +458,8 @@
},
<<<<<<< HEAD
=======
=======
>>>>>>> bef06db (Init Address.js)
"node_modules/forwarded": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
......@@ -461,6 +494,7 @@
"url": "https://github.com/sponsors/ljharb"
}
},
<<<<<<< HEAD
>>>>>>> main
"node_modules/getpass": {
"version": "0.1.7",
......@@ -493,6 +527,8 @@
},
<<<<<<< HEAD
=======
=======
>>>>>>> bef06db (Init Address.js)
"node_modules/has": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
......@@ -530,6 +566,7 @@
"node": ">= 0.8"
}
},
<<<<<<< HEAD
>>>>>>> main
"node_modules/http-signature": {
"version": "1.2.0",
......@@ -547,6 +584,8 @@
},
<<<<<<< HEAD
=======
=======
>>>>>>> bef06db (Init Address.js)
"node_modules/iconv-lite": {
"version": "0.4.24",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
......@@ -571,6 +610,7 @@
"node": ">= 0.10"
}
},
<<<<<<< HEAD
>>>>>>> main
"node_modules/is-typedarray": {
"version": "1.0.0",
......@@ -626,6 +666,8 @@
},
<<<<<<< HEAD
=======
=======
>>>>>>> bef06db (Init Address.js)
"node_modules/media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
......@@ -658,7 +700,10 @@
"node": ">=4"
}
},
<<<<<<< HEAD
>>>>>>> main
=======
>>>>>>> bef06db (Init Address.js)
"node_modules/mime-db": {
"version": "1.52.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
......@@ -679,7 +724,10 @@
}
},
<<<<<<< HEAD
<<<<<<< HEAD
=======
=======
>>>>>>> bef06db (Init Address.js)
"node_modules/ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
......@@ -693,6 +741,7 @@
"node": ">= 0.6"
}
},
<<<<<<< HEAD
"node_modules/node-fetch": {
"version": "2.6.7",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
......@@ -737,6 +786,8 @@
},
<<<<<<< HEAD
=======
=======
>>>>>>> bef06db (Init Address.js)
"node_modules/object-inspect": {
"version": "1.12.2",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.2.tgz",
......@@ -769,6 +820,7 @@
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
"integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ=="
},
<<<<<<< HEAD
>>>>>>> main
"node_modules/performance-now": {
"version": "2.1.0",
......@@ -777,6 +829,8 @@
},
<<<<<<< HEAD
=======
=======
>>>>>>> bef06db (Init Address.js)
"node_modules/proxy-addr": {
"version": "2.0.7",
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
......@@ -789,6 +843,7 @@
"node": ">= 0.10"
}
},
<<<<<<< HEAD
>>>>>>> main
"node_modules/psl": {
"version": "1.9.0",
......@@ -813,6 +868,22 @@
},
<<<<<<< HEAD
=======
=======
"node_modules/qs": {
"version": "6.11.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz",
"integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==",
"dependencies": {
"side-channel": "^1.0.4"
},
"engines": {
"node": ">=0.6"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
>>>>>>> bef06db (Init Address.js)
"node_modules/range-parser": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
......@@ -835,6 +906,7 @@
"node": ">= 0.8"
}
},
<<<<<<< HEAD
>>>>>>> main
"node_modules/request": {
"version": "2.88.2",
......@@ -867,6 +939,8 @@
"node": ">= 6"
}
},
=======
>>>>>>> bef06db (Init Address.js)
"node_modules/safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
......@@ -892,12 +966,15 @@
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
},
<<<<<<< HEAD
<<<<<<< HEAD
=======
"node_modules/sax": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz",
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw=="
},
=======
>>>>>>> bef06db (Init Address.js)
"node_modules/send": {
"version": "0.18.0",
"resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz",
......@@ -958,6 +1035,7 @@
"url": "https://github.com/sponsors/ljharb"
}
},
<<<<<<< HEAD
>>>>>>> main
"node_modules/sshpk": {
"version": "1.17.0",
......@@ -985,6 +1063,8 @@
},
<<<<<<< HEAD
=======
=======
>>>>>>> bef06db (Init Address.js)
"node_modules/statuses": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz",
......@@ -1001,6 +1081,7 @@
"node": ">=0.6"
}
},
<<<<<<< HEAD
>>>>>>> main
"node_modules/tough-cookie": {
"version": "2.5.0",
......@@ -1040,6 +1121,8 @@
},
<<<<<<< HEAD
=======
=======
>>>>>>> bef06db (Init Address.js)
"node_modules/type-is": {
"version": "1.6.18",
"resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
......@@ -1060,6 +1143,7 @@
"node": ">= 0.8"
}
},
<<<<<<< HEAD
>>>>>>> main
"node_modules/uri-js": {
"version": "4.4.1",
......@@ -1071,6 +1155,8 @@
},
<<<<<<< HEAD
=======
=======
>>>>>>> bef06db (Init Address.js)
"node_modules/utils-merge": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
......@@ -1079,6 +1165,7 @@
"node": ">= 0.4.0"
}
},
<<<<<<< HEAD
>>>>>>> main
"node_modules/uuid": {
"version": "3.4.0",
......@@ -1091,6 +1178,8 @@
},
<<<<<<< HEAD
=======
=======
>>>>>>> bef06db (Init Address.js)
"node_modules/vary": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
......@@ -1098,6 +1187,7 @@
"engines": {
"node": ">= 0.8"
}
<<<<<<< HEAD
},
>>>>>>> main
"node_modules/verror": {
......@@ -1140,6 +1230,8 @@
"xml-js": "bin/cli.js"
}
>>>>>>> main
=======
>>>>>>> bef06db (Init Address.js)
}
}
}
......
......@@ -13,6 +13,7 @@
"func-name-matching": 0,
"id-length": [2, { "min": 1, "max": 25, "properties": "never" }],
"indent": [2, 4],
<<<<<<< HEAD
"max-lines-per-function": 0,
"max-params": [2, 12],
"max-statements": [2, 45],
......@@ -20,6 +21,14 @@
"no-continue": 1,
"no-magic-numbers": 0,
"no-param-reassign": 1,
=======
"max-lines-per-function": [2, { "max": 150 }],
"max-params": [2, 16],
"max-statements": [2, 53],
"multiline-comment-style": 0,
"no-continue": 1,
"no-magic-numbers": 0,
>>>>>>> bef06db (Init Address.js)
"no-restricted-syntax": [2, "BreakStatement", "DebuggerStatement", "ForInStatement", "LabeledStatement", "WithStatement"],
},
......@@ -27,10 +36,19 @@
{
"files": "test/**",
"rules": {
<<<<<<< HEAD
"max-lines-per-function": 0,
"max-statements": 0,
"no-extend-native": 0,
"function-paren-newline": 0,
=======
"function-paren-newline": 0,
"max-lines-per-function": 0,
"max-statements": 0,
"no-buffer-constructor": 0,
"no-extend-native": 0,
"no-throw-literal": 0,
>>>>>>> bef06db (Init Address.js)
},
},
],
......
This diff is collapsed. Click to expand it.
<<<<<<< HEAD
# qs <sup>[![Version Badge][2]][1]</sup>
=======
# qs <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
>>>>>>> bef06db (Init Address.js)
[![github actions][actions-image]][actions-url]
[![coverage][codecov-image]][codecov-url]
......@@ -147,6 +151,65 @@ var withDots = qs.parse('a.b=c', { allowDots: true });
assert.deepEqual(withDots, { a: { b: 'c' } });
```
<<<<<<< HEAD
=======
If you have to deal with legacy browsers or services, there's
also support for decoding percent-encoded octets as iso-8859-1:
```javascript
var oldCharset = qs.parse('a=%A7', { charset: 'iso-8859-1' });
assert.deepEqual(oldCharset, { a: '§' });
```
Some services add an initial `utf8=✓` value to forms so that old
Internet Explorer versions are more likely to submit the form as
utf-8. Additionally, the server can check the value against wrong
encodings of the checkmark character and detect that a query string
or `application/x-www-form-urlencoded` body was *not* sent as
utf-8, eg. if the form had an `accept-charset` parameter or the
containing page had a different character set.
**qs** supports this mechanism via the `charsetSentinel` option.
If specified, the `utf8` parameter will be omitted from the
returned object. It will be used to switch to `iso-8859-1`/`utf-8`
mode depending on how the checkmark is encoded.
**Important**: When you specify both the `charset` option and the
`charsetSentinel` option, the `charset` will be overridden when
the request contains a `utf8` parameter from which the actual
charset can be deduced. In that sense the `charset` will behave
as the default charset rather than the authoritative charset.
```javascript
var detectedAsUtf8 = qs.parse('utf8=%E2%9C%93&a=%C3%B8', {
charset: 'iso-8859-1',
charsetSentinel: true
});
assert.deepEqual(detectedAsUtf8, { a: 'ø' });
// Browsers encode the checkmark as &#10003; when submitting as iso-8859-1:
var detectedAsIso8859_1 = qs.parse('utf8=%26%2310003%3B&a=%F8', {
charset: 'utf-8',
charsetSentinel: true
});
assert.deepEqual(detectedAsIso8859_1, { a: 'ø' });
```
If you want to decode the `&#...;` syntax to the actual character,
you can specify the `interpretNumericEntities` option as well:
```javascript
var detectedAsIso8859_1 = qs.parse('a=%26%239786%3B', {
charset: 'iso-8859-1',
interpretNumericEntities: true
});
assert.deepEqual(detectedAsIso8859_1, { a: '☺' });
```
It also works when the charset has been detected in `charsetSentinel`
mode.
>>>>>>> bef06db (Init Address.js)
### Parsing Arrays
**qs** can also parse arrays using a similar `[]` notation:
......@@ -172,6 +235,16 @@ var noSparse = qs.parse('a[1]=b&a[15]=c');
assert.deepEqual(noSparse, { a: ['b', 'c'] });
```
<<<<<<< HEAD
=======
You may also use `allowSparse` option to parse sparse arrays:
```javascript
var sparseArray = qs.parse('a[1]=2&a[3]=5', { allowSparse: true });
assert.deepEqual(sparseArray, { a: [, '2', , '5'] });
```
>>>>>>> bef06db (Init Address.js)
Note that an empty string is also a value, and will be preserved:
```javascript
......@@ -218,6 +291,27 @@ var arraysOfObjects = qs.parse('a[][b]=c');
assert.deepEqual(arraysOfObjects, { a: [{ b: 'c' }] });
```
<<<<<<< HEAD
=======
Some people use comma to join array, **qs** can parse it:
```javascript
var arraysOfObjects = qs.parse('a=b,c', { comma: true })
assert.deepEqual(arraysOfObjects, { a: ['b', 'c'] })
```
(_this cannot convert nested objects, such as `a={b:1},{c:d}`_)
### Parsing primitive/scalar values (numbers, booleans, null, etc)
By default, all values are parsed as strings. This behavior will not change and is explained in [issue #91](https://github.com/ljharb/qs/issues/91).
```javascript
var primitiveValues = qs.parse('a=15&b=true&c=null');
assert.deepEqual(primitiveValues, { a: '15', b: 'true', c: 'null' });
```
If you wish to auto-convert values which look like numbers, booleans, and other values into their primitive counterparts, you can use the [query-types Express JS middleware](https://github.com/xpepermint/query-types) which will auto-convert all request query parameters.
>>>>>>> bef06db (Init Address.js)
### Stringifying
[](#preventEval)
......@@ -317,8 +411,17 @@ qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'brackets' })
// 'a[]=b&a[]=c'
qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'repeat' })
// 'a=b&a=c'
<<<<<<< HEAD
```
=======
qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'comma' })
// 'a=b,c'
```
Note: when using `arrayFormat` set to `'comma'`, you can also pass the `commaRoundTrip` option set to `true` or `false`, to append `[]` on single-item arrays, so that they can round trip through a parse.
>>>>>>> bef06db (Init Address.js)
When objects are stringified, by default they use bracket notation:
```javascript
......@@ -451,10 +554,47 @@ var nullsSkipped = qs.stringify({ a: 'b', c: null}, { skipNulls: true });
assert.equal(nullsSkipped, 'a=b');
```
<<<<<<< HEAD
### Dealing with special character sets
By default the encoding and decoding of characters is done in `utf-8`. If you
wish to encode querystrings to a different character set (i.e.
=======
If you're communicating with legacy systems, you can switch to `iso-8859-1`
using the `charset` option:
```javascript
var iso = qs.stringify({ æ: 'æ' }, { charset: 'iso-8859-1' });
assert.equal(iso, '%E6=%E6');
```
Characters that don't exist in `iso-8859-1` will be converted to numeric
entities, similar to what browsers do:
```javascript
var numeric = qs.stringify({ a: '☺' }, { charset: 'iso-8859-1' });
assert.equal(numeric, 'a=%26%239786%3B');
```
You can use the `charsetSentinel` option to announce the character by
including an `utf8=✓` parameter with the proper encoding if the checkmark,
similar to what Ruby on Rails and others do when submitting forms.
```javascript
var sentinel = qs.stringify({ a: '☺' }, { charsetSentinel: true });
assert.equal(sentinel, 'utf8=%E2%9C%93&a=%E2%98%BA');
var isoSentinel = qs.stringify({ a: 'æ' }, { charsetSentinel: true, charset: 'iso-8859-1' });
assert.equal(isoSentinel, 'utf8=%26%2310003%3B&a=%E6');
```
### Dealing with special character sets
By default the encoding and decoding of characters is done in `utf-8`,
and `iso-8859-1` support is also built in via the `charset` parameter.
If you wish to encode querystrings to a different character set (i.e.
>>>>>>> bef06db (Init Address.js)
[Shift JIS](https://en.wikipedia.org/wiki/Shift_JIS)) you can use the
[`qs-iconv`](https://github.com/martinheidegger/qs-iconv) library:
......
This diff is collapsed. Click to expand it.
......@@ -3,8 +3,18 @@
var replace = String.prototype.replace;
var percentTwenties = /%20/g;
<<<<<<< HEAD
module.exports = {
'default': 'RFC3986',
=======
var Format = {
RFC1738: 'RFC1738',
RFC3986: 'RFC3986'
};
module.exports = {
'default': Format.RFC3986,
>>>>>>> bef06db (Init Address.js)
formatters: {
RFC1738: function (value) {
return replace.call(value, percentTwenties, '+');
......@@ -13,6 +23,11 @@ module.exports = {
return String(value);
}
},
<<<<<<< HEAD
RFC1738: 'RFC1738',
RFC3986: 'RFC3986'
=======
RFC1738: Format.RFC1738,
RFC3986: Format.RFC3986
>>>>>>> bef06db (Init Address.js)
};
......
......@@ -3,26 +3,97 @@
var utils = require('./utils');
var has = Object.prototype.hasOwnProperty;
<<<<<<< HEAD
=======
var isArray = Array.isArray;
>>>>>>> bef06db (Init Address.js)
var defaults = {
allowDots: false,
allowPrototypes: false,
<<<<<<< HEAD
arrayLimit: 20,
decoder: utils.decode,
delimiter: '&',
depth: 5,
parameterLimit: 1000,
=======
allowSparse: false,
arrayLimit: 20,
charset: 'utf-8',
charsetSentinel: false,
comma: false,
decoder: utils.decode,
delimiter: '&',
depth: 5,
ignoreQueryPrefix: false,
interpretNumericEntities: false,
parameterLimit: 1000,
parseArrays: true,
>>>>>>> bef06db (Init Address.js)
plainObjects: false,
strictNullHandling: false
};
<<<<<<< HEAD
=======
var interpretNumericEntities = function (str) {
return str.replace(/&#(\d+);/g, function ($0, numberStr) {
return String.fromCharCode(parseInt(numberStr, 10));
});
};
var parseArrayValue = function (val, options) {
if (val && typeof val === 'string' && options.comma && val.indexOf(',') > -1) {
return val.split(',');
}
return val;
};
// This is what browsers will submit when the ✓ character occurs in an
// application/x-www-form-urlencoded body and the encoding of the page containing
// the form is iso-8859-1, or when the submitted form has an accept-charset
// attribute of iso-8859-1. Presumably also with other charsets that do not contain
// the ✓ character, such as us-ascii.
var isoSentinel = 'utf8=%26%2310003%3B'; // encodeURIComponent('&#10003;')
// These are the percent-encoded utf-8 octets representing a checkmark, indicating that the request actually is utf-8 encoded.
var charsetSentinel = 'utf8=%E2%9C%93'; // encodeURIComponent('✓')
>>>>>>> bef06db (Init Address.js)
var parseValues = function parseQueryStringValues(str, options) {
var obj = {};
var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, '') : str;
var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit;
var parts = cleanStr.split(options.delimiter, limit);
<<<<<<< HEAD
for (var i = 0; i < parts.length; ++i) {
=======
var skipIndex = -1; // Keep track of where the utf8 sentinel was found
var i;
var charset = options.charset;
if (options.charsetSentinel) {
for (i = 0; i < parts.length; ++i) {
if (parts[i].indexOf('utf8=') === 0) {
if (parts[i] === charsetSentinel) {
charset = 'utf-8';
} else if (parts[i] === isoSentinel) {
charset = 'iso-8859-1';
}
skipIndex = i;
i = parts.length; // The eslint settings do not allow break;
}
}
}
for (i = 0; i < parts.length; ++i) {
if (i === skipIndex) {
continue;
}
>>>>>>> bef06db (Init Address.js)
var part = parts[i];
var bracketEqualsPos = part.indexOf(']=');
......@@ -30,6 +101,7 @@ var parseValues = function parseQueryStringValues(str, options) {
var key, val;
if (pos === -1) {
<<<<<<< HEAD
key = options.decoder(part, defaults.decoder);
val = options.strictNullHandling ? null : '';
} else {
......@@ -38,6 +110,30 @@ var parseValues = function parseQueryStringValues(str, options) {
}
if (has.call(obj, key)) {
obj[key] = [].concat(obj[key]).concat(val);
=======
key = options.decoder(part, defaults.decoder, charset, 'key');
val = options.strictNullHandling ? null : '';
} else {
key = options.decoder(part.slice(0, pos), defaults.decoder, charset, 'key');
val = utils.maybeMap(
parseArrayValue(part.slice(pos + 1), options),
function (encodedVal) {
return options.decoder(encodedVal, defaults.decoder, charset, 'value');
}
);
}
if (val && options.interpretNumericEntities && charset === 'iso-8859-1') {
val = interpretNumericEntities(val);
}
if (part.indexOf('[]=') > -1) {
val = isArray(val) ? [val] : val;
}
if (has.call(obj, key)) {
obj[key] = utils.combine(obj[key], val);
>>>>>>> bef06db (Init Address.js)
} else {
obj[key] = val;
}
......@@ -46,8 +142,13 @@ var parseValues = function parseQueryStringValues(str, options) {
return obj;
};
<<<<<<< HEAD
var parseObject = function (chain, val, options) {
var leaf = val;
=======
var parseObject = function (chain, val, options, valuesParsed) {
var leaf = valuesParsed ? val : parseArrayValue(val, options);
>>>>>>> bef06db (Init Address.js)
for (var i = chain.length - 1; i >= 0; --i) {
var obj;
......@@ -81,7 +182,11 @@ var parseObject = function (chain, val, options) {
return leaf;
};
<<<<<<< HEAD
var parseKeys = function parseQueryStringKeys(givenKey, val, options) {
=======
var parseKeys = function parseQueryStringKeys(givenKey, val, options, valuesParsed) {
>>>>>>> bef06db (Init Address.js)
if (!givenKey) {
return;
}
......@@ -96,15 +201,23 @@ var parseKeys = function parseQueryStringKeys(givenKey, val, options) {
// Get the parent
<<<<<<< HEAD
var segment = brackets.exec(key);
=======
var segment = options.depth > 0 && brackets.exec(key);
>>>>>>> bef06db (Init Address.js)
var parent = segment ? key.slice(0, segment.index) : key;
// Stash the parent if it exists
var keys = [];
if (parent) {
<<<<<<< HEAD
// If we aren't using plain objects, optionally prefix keys
// that would overwrite object prototype properties
=======
// If we aren't using plain objects, optionally prefix keys that would overwrite object prototype properties
>>>>>>> bef06db (Init Address.js)
if (!options.plainObjects && has.call(Object.prototype, parent)) {
if (!options.allowPrototypes) {
return;
......@@ -117,7 +230,11 @@ var parseKeys = function parseQueryStringKeys(givenKey, val, options) {
// Loop through children appending to the array until we hit depth
var i = 0;
<<<<<<< HEAD
while ((segment = child.exec(key)) !== null && i < options.depth) {
=======
while (options.depth > 0 && (segment = child.exec(key)) !== null && i < options.depth) {
>>>>>>> bef06db (Init Address.js)
i += 1;
if (!options.plainObjects && has.call(Object.prototype, segment[1].slice(1, -1))) {
if (!options.allowPrototypes) {
......@@ -133,6 +250,7 @@ var parseKeys = function parseQueryStringKeys(givenKey, val, options) {
keys.push('[' + key.slice(segment.index) + ']');
}
<<<<<<< HEAD
return parseObject(keys, val, options);
};
......@@ -154,6 +272,48 @@ module.exports = function (str, opts) {
options.allowPrototypes = typeof options.allowPrototypes === 'boolean' ? options.allowPrototypes : defaults.allowPrototypes;
options.parameterLimit = typeof options.parameterLimit === 'number' ? options.parameterLimit : defaults.parameterLimit;
options.strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling;
=======
return parseObject(keys, val, options, valuesParsed);
};
var normalizeParseOptions = function normalizeParseOptions(opts) {
if (!opts) {
return defaults;
}
if (opts.decoder !== null && opts.decoder !== undefined && typeof opts.decoder !== 'function') {
throw new TypeError('Decoder has to be a function.');
}
if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {
throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined');
}
var charset = typeof opts.charset === 'undefined' ? defaults.charset : opts.charset;
return {
allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots,
allowPrototypes: typeof opts.allowPrototypes === 'boolean' ? opts.allowPrototypes : defaults.allowPrototypes,
allowSparse: typeof opts.allowSparse === 'boolean' ? opts.allowSparse : defaults.allowSparse,
arrayLimit: typeof opts.arrayLimit === 'number' ? opts.arrayLimit : defaults.arrayLimit,
charset: charset,
charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel,
comma: typeof opts.comma === 'boolean' ? opts.comma : defaults.comma,
decoder: typeof opts.decoder === 'function' ? opts.decoder : defaults.decoder,
delimiter: typeof opts.delimiter === 'string' || utils.isRegExp(opts.delimiter) ? opts.delimiter : defaults.delimiter,
// eslint-disable-next-line no-implicit-coercion, no-extra-parens
depth: (typeof opts.depth === 'number' || opts.depth === false) ? +opts.depth : defaults.depth,
ignoreQueryPrefix: opts.ignoreQueryPrefix === true,
interpretNumericEntities: typeof opts.interpretNumericEntities === 'boolean' ? opts.interpretNumericEntities : defaults.interpretNumericEntities,
parameterLimit: typeof opts.parameterLimit === 'number' ? opts.parameterLimit : defaults.parameterLimit,
parseArrays: opts.parseArrays !== false,
plainObjects: typeof opts.plainObjects === 'boolean' ? opts.plainObjects : defaults.plainObjects,
strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling
};
};
module.exports = function (str, opts) {
var options = normalizeParseOptions(opts);
>>>>>>> bef06db (Init Address.js)
if (str === '' || str === null || typeof str === 'undefined') {
return options.plainObjects ? Object.create(null) : {};
......@@ -167,9 +327,20 @@ module.exports = function (str, opts) {
var keys = Object.keys(tempObj);
for (var i = 0; i < keys.length; ++i) {
var key = keys[i];
<<<<<<< HEAD
var newObj = parseKeys(key, tempObj[key], options);
obj = utils.merge(obj, newObj, options);
}
=======
var newObj = parseKeys(key, tempObj[key], options, typeof str === 'string');
obj = utils.merge(obj, newObj, options);
}
if (options.allowSparse === true) {
return obj;
}
>>>>>>> bef06db (Init Address.js)
return utils.compact(obj);
};
......
This diff is collapsed. Click to expand it.
'use strict';
<<<<<<< HEAD
var has = Object.prototype.hasOwnProperty;
=======
var formats = require('./formats');
var has = Object.prototype.hasOwnProperty;
var isArray = Array.isArray;
>>>>>>> bef06db (Init Address.js)
var hexTable = (function () {
var array = [];
......@@ -12,6 +19,7 @@ var hexTable = (function () {
}());
var compactQueue = function compactQueue(queue) {
<<<<<<< HEAD
var obj;
while (queue.length) {
......@@ -19,6 +27,13 @@ var compactQueue = function compactQueue(queue) {
obj = item.obj[item.prop];
if (Array.isArray(obj)) {
=======
while (queue.length > 1) {
var item = queue.pop();
var obj = item.obj[item.prop];
if (isArray(obj)) {
>>>>>>> bef06db (Init Address.js)
var compacted = [];
for (var j = 0; j < obj.length; ++j) {
......@@ -30,8 +45,11 @@ var compactQueue = function compactQueue(queue) {
item.obj[item.prop] = compacted;
}
}
<<<<<<< HEAD
return obj;
=======
>>>>>>> bef06db (Init Address.js)
};
var arrayToObject = function arrayToObject(source, options) {
......@@ -46,12 +64,20 @@ var arrayToObject = function arrayToObject(source, options) {
};
var merge = function merge(target, source, options) {
<<<<<<< HEAD
=======
/* eslint no-param-reassign: 0 */
>>>>>>> bef06db (Init Address.js)
if (!source) {
return target;
}
if (typeof source !== 'object') {
<<<<<<< HEAD
if (Array.isArray(target)) {
=======
if (isArray(target)) {
>>>>>>> bef06db (Init Address.js)
target.push(source);
} else if (target && typeof target === 'object') {
if ((options && (options.plainObjects || options.allowPrototypes)) || !has.call(Object.prototype, source)) {
......@@ -69,11 +95,19 @@ var merge = function merge(target, source, options) {
}
var mergeTarget = target;
<<<<<<< HEAD
if (Array.isArray(target) && !Array.isArray(source)) {
mergeTarget = arrayToObject(target, options);
}
if (Array.isArray(target) && Array.isArray(source)) {
=======
if (isArray(target) && !isArray(source)) {
mergeTarget = arrayToObject(target, options);
}
if (isArray(target) && isArray(source)) {
>>>>>>> bef06db (Init Address.js)
source.forEach(function (item, i) {
if (has.call(target, i)) {
var targetItem = target[i];
......@@ -108,6 +142,7 @@ var assign = function assignSingleSource(target, source) {
}, target);
};
<<<<<<< HEAD
var decode = function (str) {
try {
return decodeURIComponent(str.replace(/\+/g, ' '));
......@@ -117,13 +152,45 @@ var decode = function (str) {
};
var encode = function encode(str) {
=======
var decode = function (str, decoder, charset) {
var strWithoutPlus = str.replace(/\+/g, ' ');
if (charset === 'iso-8859-1') {
// unescape never throws, no try...catch needed:
return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape);
}
// utf-8
try {
return decodeURIComponent(strWithoutPlus);
} catch (e) {
return strWithoutPlus;
}
};
var encode = function encode(str, defaultEncoder, charset, kind, format) {
>>>>>>> bef06db (Init Address.js)
// This code was originally written by Brian White (mscdex) for the io.js core querystring library.
// It has been adapted here for stricter adherence to RFC 3986
if (str.length === 0) {
return str;
}
<<<<<<< HEAD
var string = typeof str === 'string' ? str : String(str);
=======
var string = str;
if (typeof str === 'symbol') {
string = Symbol.prototype.toString.call(str);
} else if (typeof str !== 'string') {
string = String(str);
}
if (charset === 'iso-8859-1') {
return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) {
return '%26%23' + parseInt($0.slice(2), 16) + '%3B';
});
}
>>>>>>> bef06db (Init Address.js)
var out = '';
for (var i = 0; i < string.length; ++i) {
......@@ -137,6 +204,10 @@ var encode = function encode(str) {
|| (c >= 0x30 && c <= 0x39) // 0-9
|| (c >= 0x41 && c <= 0x5A) // a-z
|| (c >= 0x61 && c <= 0x7A) // A-Z
<<<<<<< HEAD
=======
|| (format === formats.RFC1738 && (c === 0x28 || c === 0x29)) // ( )
>>>>>>> bef06db (Init Address.js)
) {
out += string.charAt(i);
continue;
......@@ -188,7 +259,13 @@ var compact = function compact(value) {
}
}
<<<<<<< HEAD
return compactQueue(queue);
=======
compactQueue(queue);
return value;
>>>>>>> bef06db (Init Address.js)
};
var isRegExp = function isRegExp(obj) {
......@@ -196,20 +273,50 @@ var isRegExp = function isRegExp(obj) {
};
var isBuffer = function isBuffer(obj) {
<<<<<<< HEAD
if (obj === null || typeof obj === 'undefined') {
=======
if (!obj || typeof obj !== 'object') {
>>>>>>> bef06db (Init Address.js)
return false;
}
return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
};
<<<<<<< HEAD
module.exports = {
arrayToObject: arrayToObject,
assign: assign,
=======
var combine = function combine(a, b) {
return [].concat(a, b);
};
var maybeMap = function maybeMap(val, fn) {
if (isArray(val)) {
var mapped = [];
for (var i = 0; i < val.length; i += 1) {
mapped.push(fn(val[i]));
}
return mapped;
}
return fn(val);
};
module.exports = {
arrayToObject: arrayToObject,
assign: assign,
combine: combine,
>>>>>>> bef06db (Init Address.js)
compact: compact,
decode: decode,
encode: encode,
isBuffer: isBuffer,
isRegExp: isRegExp,
<<<<<<< HEAD
=======
maybeMap: maybeMap,
>>>>>>> bef06db (Init Address.js)
merge: merge
};
......
......@@ -2,11 +2,21 @@
"name": "qs",
"description": "A querystring parser that supports nesting and arrays, with a depth limit",
"homepage": "https://github.com/ljharb/qs",
<<<<<<< HEAD
"version": "6.5.3",
=======
"version": "6.11.0",
>>>>>>> bef06db (Init Address.js)
"repository": {
"type": "git",
"url": "https://github.com/ljharb/qs.git"
},
<<<<<<< HEAD
=======
"funding": {
"url": "https://github.com/sponsors/ljharb"
},
>>>>>>> bef06db (Init Address.js)
"main": "lib/index.js",
"contributors": [
{
......@@ -17,11 +27,20 @@
],
"keywords": [
"querystring",
<<<<<<< HEAD
"qs"
=======
"qs",
"query",
"url",
"parse",
"stringify"
>>>>>>> bef06db (Init Address.js)
],
"engines": {
"node": ">=0.6"
},
<<<<<<< HEAD
"devDependencies": {
"@ljharb/eslint-config": "^20.1.0",
"aud": "^1.1.5",
......@@ -51,4 +70,51 @@
"dist": "mkdirp dist && browserify --standalone Qs lib/index.js > dist/qs.js"
},
"license": "BSD-3-Clause"
=======
"dependencies": {
"side-channel": "^1.0.4"
},
"devDependencies": {
"@ljharb/eslint-config": "^21.0.0",
"aud": "^2.0.0",
"browserify": "^16.5.2",
"eclint": "^2.8.1",
"eslint": "=8.8.0",
"evalmd": "^0.0.19",
"for-each": "^0.3.3",
"has-symbols": "^1.0.3",
"iconv-lite": "^0.5.1",
"in-publish": "^2.0.1",
"mkdirp": "^0.5.5",
"npmignore": "^0.3.0",
"nyc": "^10.3.2",
"object-inspect": "^1.12.2",
"qs-iconv": "^1.0.4",
"safe-publish-latest": "^2.0.0",
"safer-buffer": "^2.1.2",
"tape": "^5.5.3"
},
"scripts": {
"prepack": "npmignore --auto --commentLines=autogenerated",
"prepublishOnly": "safe-publish-latest && npm run dist",
"prepublish": "not-in-publish || npm run prepublishOnly",
"pretest": "npm run --silent readme && npm run --silent lint",
"test": "npm run tests-only",
"tests-only": "nyc tape 'test/**/*.js'",
"posttest": "aud --production",
"readme": "evalmd README.md",
"postlint": "eclint check $(git ls-files | xargs find 2> /dev/null | grep -vE 'node_modules|\\.git' | grep -v dist/)",
"lint": "eslint --ext=js,mjs .",
"dist": "mkdirp dist && browserify --standalone Qs lib/index.js > dist/qs.js"
},
"license": "BSD-3-Clause",
"publishConfig": {
"ignore": [
"!dist/*",
"bower.json",
"component.json",
".github/workflows"
]
}
>>>>>>> bef06db (Init Address.js)
}
......
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
'use strict';
var test = require('tape');
<<<<<<< HEAD
=======
var inspect = require('object-inspect');
var SaferBuffer = require('safer-buffer').Buffer;
var forEach = require('for-each');
>>>>>>> bef06db (Init Address.js)
var utils = require('../lib/utils');
test('merge()', function (t) {
......@@ -63,3 +69,74 @@ test('assign()', function (t) {
t.end();
});
<<<<<<< HEAD
=======
test('combine()', function (t) {
t.test('both arrays', function (st) {
var a = [1];
var b = [2];
var combined = utils.combine(a, b);
st.deepEqual(a, [1], 'a is not mutated');
st.deepEqual(b, [2], 'b is not mutated');
st.notEqual(a, combined, 'a !== combined');
st.notEqual(b, combined, 'b !== combined');
st.deepEqual(combined, [1, 2], 'combined is a + b');
st.end();
});
t.test('one array, one non-array', function (st) {
var aN = 1;
var a = [aN];
var bN = 2;
var b = [bN];
var combinedAnB = utils.combine(aN, b);
st.deepEqual(b, [bN], 'b is not mutated');
st.notEqual(aN, combinedAnB, 'aN + b !== aN');
st.notEqual(a, combinedAnB, 'aN + b !== a');
st.notEqual(bN, combinedAnB, 'aN + b !== bN');
st.notEqual(b, combinedAnB, 'aN + b !== b');
st.deepEqual([1, 2], combinedAnB, 'first argument is array-wrapped when not an array');
var combinedABn = utils.combine(a, bN);
st.deepEqual(a, [aN], 'a is not mutated');
st.notEqual(aN, combinedABn, 'a + bN !== aN');
st.notEqual(a, combinedABn, 'a + bN !== a');
st.notEqual(bN, combinedABn, 'a + bN !== bN');
st.notEqual(b, combinedABn, 'a + bN !== b');
st.deepEqual([1, 2], combinedABn, 'second argument is array-wrapped when not an array');
st.end();
});
t.test('neither is an array', function (st) {
var combined = utils.combine(1, 2);
st.notEqual(1, combined, '1 + 2 !== 1');
st.notEqual(2, combined, '1 + 2 !== 2');
st.deepEqual([1, 2], combined, 'both arguments are array-wrapped when not an array');
st.end();
});
t.end();
});
test('isBuffer()', function (t) {
forEach([null, undefined, true, false, '', 'abc', 42, 0, NaN, {}, [], function () {}, /a/g], function (x) {
t.equal(utils.isBuffer(x), false, inspect(x) + ' is not a buffer');
});
var fakeBuffer = { constructor: Buffer };
t.equal(utils.isBuffer(fakeBuffer), false, 'fake buffer is not a buffer');
var saferBuffer = SaferBuffer.from('abc');
t.equal(utils.isBuffer(saferBuffer), true, 'SaferBuffer instance is a buffer');
var buffer = Buffer.from && Buffer.alloc ? Buffer.from('abc') : new Buffer('abc');
t.equal(utils.isBuffer(buffer), true, 'real Buffer instance is a buffer');
t.end();
});
>>>>>>> bef06db (Init Address.js)
......
This diff is collapsed. Click to expand it.
{
"dependencies": {
<<<<<<< HEAD
<<<<<<< HEAD
"request": "^2.88.2"
=======
"express": "^4.18.2",
......@@ -9,5 +10,8 @@
"request": "^2.88.2",
"xml-js": "^1.6.11"
>>>>>>> main
=======
"express": "^4.18.2"
>>>>>>> bef06db (Init Address.js)
}
}
......