diff --git a/josa.js b/josa.js index 0cfc772..9cbabef 100644 --- a/josa.js +++ b/josa.js @@ -13,7 +13,7 @@ return _hasJong(string) ? '과' : '와'; }, function(string){ //으로/로 구분 - return _hasJong(string) ? '으로' : '로'; + return _hasJong(string) ? (_noRieulJong(string) ? '으로' : '로') : '로'; } ], _formats = { @@ -44,6 +44,11 @@ return (string - 0xac00) % 28 > 0; } + function _noRieulJong(string){ //string의 마지막 글자가 리을 받침이 아닌 다른 받침을 가지는지 확인 + string = string.charCodeAt(string.length - 1); + return (string - 0xac08) % 28 > 0; + } + var josa = { c: function(word, format){ if (typeof _formats[format] === 'undefined') throw 'Invalid format!'; diff --git a/test/index.js b/test/index.js index 2c82472..fc69ccf 100644 --- a/test/index.js +++ b/test/index.js @@ -55,6 +55,11 @@ $(function(){ '으로', "Josa.c('도심', '으로')" ); + assert.deepEqual( + Josa.c('강물', '으로/로'), + '로', + "Josa.c('강물', '로')" + ); }); QUnit.test ('Josa.r', function(assert){ assert.deepEqual(