Skip to content

Commit

Permalink
Fix file tree
Browse files Browse the repository at this point in the history
  • Loading branch information
kamataryo committed Jul 29, 2023
1 parent 87ba35b commit cc2a4a8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"test:node:platform": "npm run test:node-win || npm run test:node",
"test:main": "jest test/main.test.ts",
"test:addresses": "jest test/addresses.test.ts",
"test:advanced": "jest test/advanced_v?.test.ts --runInBand",
"test:advanced": "jest test/advanced/*.test.ts --runInBand",
"test:util": "jest test/util.test.ts",
"test:node": "curl -sL https://github.com/geolonia/japanese-addresses/archive/refs/heads/master.tar.gz | tar xvfz - -C ./test > nul 2>&1 && jest test/fs.test.ts",
"test:node-win": "curl -sL https://github.com/geolonia/japanese-addresses/archive/refs/heads/master.tar.gz -o master.tar.gz && 7z x master.tar.gz -y -o./ && 7z x ./master.tar -y -o./test && del master.tar.gz master.tar && jest test/fs.test.ts",
Expand Down
4 changes: 3 additions & 1 deletion src/normalize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export interface Config {
/**
* レスポンス型のバージョン。デフォルト 1
* 1 の場合は jyukyo: string, gaiku: string
* 2 の場合は addr: string, type: 'GAIKU' | 'CHIBAN'
* 2 の場合は addr: string, other: string
*/
interfaceVersion: number

Expand All @@ -51,6 +51,7 @@ export interface Config {
/** 町丁目のデータを何件までキャッシュするか。デフォルト 1,000 */
townCacheSize: number

/** 住所データへのリクエストを変形するオプション。 interfaceVersion === 2 で有効 */
transformRequest?: TransformRequestFunction

geoloniaApiKey?: string
Expand Down Expand Up @@ -490,6 +491,7 @@ export const normalize: Normalizer = async (
// 将来的に v2 に統一することを検討中
// ==================================================================

// v2 のインターフェース
if (currentConfig.interfaceVersion === 2) {
const normalizedAddrPart = await normalizeAddrPart(addr, pref, city, town)
let other = undefined
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as Normalize from '../src/normalize'
import { normalize } from '../src/main-node'
import * as Normalize from '../../src/normalize'
import { normalize } from '../../src/main-node'
import unfetch from 'isomorphic-unfetch'
import { gh_pages_endpoint } from '../src/config'
import { gh_pages_endpoint } from '../../src/config'

// interfaceVersion 1 に対するテスト。
// interfaceVersion 1 に対するテスト。(デフォルト設定)
// prop ID でのみ利用。
// interfaceVersion 1 は廃止予定。

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { normalize, config } from '../src/main-node'
import { normalize, config } from '../../src/main-node'

config.interfaceVersion = 2
config.transformRequest = async (url, query) => {
Expand Down Expand Up @@ -30,8 +30,10 @@ config.transformRequest = async (url, query) => {
}

// interfaceVersion 2 に対するテスト。
// transformRequest を使った柔軟なリクエストが可能なバージョン。
// 将来的に 1 を廃止し、こちらをデフォルトにする予定。
// addr として住居表示または地番を返す。
// addr 以降の列は other として返す。
// transformRequest が使用可能。
// 将来的にこちらをデフォルトにする予定。

test('リクエスト変形テスト 1', async () => {
const res = await normalize('A県 X市 あああ 1の2おはようビル', { level: 3 })
Expand Down

0 comments on commit cc2a4a8

Please sign in to comment.