korrect-js 1.0.2 → 1.0.4

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.
Files changed (2) hide show
  1. package/lib/check.js +9 -1
  2. package/package.json +1 -1
package/lib/check.js CHANGED
@@ -1,5 +1,12 @@
1
1
  const axios = require('axios');
2
2
 
3
+ async function getPassportKey() {
4
+ const url = "https://search.naver.com/search.naver?query=%EB%A7%9E%EC%B6%A4%EB%B2%95%EA%B2%80%EC%82%AC%EA%B8%B0"
5
+ const data = (await axios.get(url)).data
6
+ const passportKey = data.match(/passportKey=([a-f0-9]{40})/i)[1]
7
+ return passportKey
8
+ }
9
+
3
10
  /**
4
11
  * 문장의 맞춤법을 검사하고 교정된 결과를 반환합니다.
5
12
  * @param {string} text - 맞춤법을 검사할 문장
@@ -13,7 +20,8 @@ async function check(text) {
13
20
 
14
21
  try {
15
22
  const encodedText = encodeURIComponent(text);
16
- const url = `https://ts-proxy.naver.com/ocontent/util/SpellerProxy?passportKey=12e3a39878a34a48ba1dfd7203522054aa417829&q=${encodedText}&where=nexearch&color_blindness=0`;
23
+ const passportKey = await getPassportKey()
24
+ const url = `https://ts-proxy.naver.com/ocontent/util/SpellerProxy?passportKey=${passportKey}&q=${encodedText}&where=nexearch&color_blindness=0`;
17
25
 
18
26
  const response = await axios.get(url);
19
27
  const result = response.data.message.result;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "korrect-js",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {