azu / kuromojin

Provide a high-level wrapper for kuromoji.js. Cache/Promise API
https://kuromojin.netlify.app/
MIT License
88 stars 9 forks source link

CDN not found because of path.join in Kuromoji.js #12

Open qqpann opened 3 years ago

qqpann commented 3 years ago

https://nodejs.org/api/path.html#path_path_join_paths https://github.com/takuyaa/kuromoji.js/blob/71ea8473bd119546977f22c61e4d52da28ac30a6/src/loader/DictionaryLoader.js#L51 After path.join, "https://" becomes "https:/" and causes 404 error in a browser.

In my use case, I use kuromojin in a web application and this results in "https://cdn.example.com/dict" to be "https://myapp.com/cdn.example.com/dict"and getTokenizer cannot find the dict files.

qqpann commented 3 years ago

https://github.com/textlint/editor/blob/630fd1ee938a2b39e8ae74afdbde157497125557/packages/%40textlint/script-compiler/patch/kuromoji.js#L50 https://github.com/textlint/editor/blob/630fd1ee938a2b39e8ae74afdbde157497125557/packages/%40textlint/script-compiler/src/compiler.ts#L86 I found there is α repository that makes original patch to deal with τhis problem. This might be α good reference.

azu commented 3 years ago

https://github.com/takuyaa/kuromoji.js/issues/37 This is kuromoji.js issue