Kennitala icon indicating copy to clipboard operation
Kennitala copied to clipboard

Package doesn't support the new "Gerviþjóðskrá".

Open gudmundurm opened this issue 1 year ago • 6 comments

Hi, there is a bug/problem here. The package doesn't support the new "gerviþjóðskrá". https://www.skra.is/um-okkur/frettir/frett/2020/10/13/Ny-utgafa-af-gervigognum-thjodskrar/

Those fake kennitala's have got either 14 or 15 in char 7-8. The package assumes 20 at the lowest.

gudmundurm avatar Sep 11 '23 12:09 gudmundurm

Thanks for letting me know!

I tried searching a while ago for fake datasets like these but didn't find them.

I think it's a good idea to support the fake dataset but I don't know if they should be supported by default or if they should be enabled when running in your development environment. What do you think?

If you need a quick fix I suggest using patch-package and updating the kennitala.js file in your node_modules folder. If you update the main property in package.json to kennitala.js you can just edit the unobfuscated file.

package.json 4: "main": "kennitala.js",

Then the change you would want is just returning true if the 7th and 8th characters are 14 or 15.

You can do that by updating kennitala.js locally and add this snippet below line 138

https://github.com/HermannBjorgvin/Kennitala/blob/c70521ace9fe01cc4b03db49f065337c2c85eec4/kennitala.js#L138

Here you could just put something like

return kt.substr(6, 1) === '1' && (kt.substr(7, 1) === '4' || kt.substr(7, 1) === '5')

HermannBjorgvin avatar Sep 15 '23 12:09 HermannBjorgvin

Will try to update this package in the next to weeks and get a V2 out of beta with support for the new system ID's and the testing dataset.

HermannBjorgvin avatar Sep 15 '23 12:09 HermannBjorgvin

Thanks @HermannBjorgvin , I think the fake dataset should be supported by default. Perhaps the check on char 7/8 is bit of an overkill ?

gudmundurm avatar Sep 15 '23 13:09 gudmundurm

I guess an argument could be made for either one. Will default to allowing the fake dataset then.

HermannBjorgvin avatar Sep 18 '23 12:09 HermannBjorgvin

@gudmundurm try this beta version here https://www.npmjs.com/package/kennitala/v/2.0.0-beta.2

HermannBjorgvin avatar Sep 22 '23 13:09 HermannBjorgvin

@gudmundurm leysti þetta í v2.0.0-beta.3

HermannBjorgvin avatar Nov 20 '23 15:11 HermannBjorgvin