Added alphabet check before decoding #7

Открыто
Ghost хочет влить 3 коммит(ов) из (удалена):master в master
Ghost прокомментировал(а) 2021-03-04 05:12:49 +00:00
First-time contributor

Resolves #6

Linear time complexity solution, guaranteed to work.

Alternatively you could check the expected length of the output matches but then you will have to deal with edge cases (such as the test case given).

Resolves #6 Linear time complexity solution, guaranteed to work. Alternatively you could check the expected length of the output matches but then you will have to deal with edge cases (such as the test case given).
Ghost добавил(а) 1 коммит 2021-03-04 05:12:50 +00:00
coolaj86 прокомментировал(а) 2021-03-10 19:16:26 +00:00
Владелец

I'm open to updating this, but it's so old an relied on so heavily by so many projects and devices (including the AppleTV SDK) that I think I'll have to do a major version bump even for a bugfix.

You could actually make this quite a bit faster by checking character ranges.

// off the cuff, not correct code
if (!(x >= "a".toCharCode() && x <= "Z".toCharCode() /* && range of symbols*/)) {
   throw Error('barf');
}

Also, I want to stick with Vanilla JavaScript (ES5) so that, for those who update, they don't have to introduce a compiler or change their other build tools.

I'm open to updating this, but it's so old an relied on so heavily by so many projects and devices (including the AppleTV SDK) that I think I'll have to do a major version bump even for a bugfix. You could actually make this quite a bit faster by checking character ranges. ```js // off the cuff, not correct code if (!(x >= "a".toCharCode() && x <= "Z".toCharCode() /* && range of symbols*/)) { throw Error('barf'); } ``` Also, I want to stick with Vanilla JavaScript (ES5) so that, for those who update, they don't have to introduce a compiler or change their other build tools.
Ghost добавил(а) 1 коммит 2021-03-11 13:26:24 +00:00
Ghost добавил(а) 1 коммит 2021-03-11 13:27:27 +00:00
Ghost прокомментировал(а) 2021-03-11 13:43:12 +00:00
Автор
First-time contributor

I changed it to a range check (good advice).

I think I've changed it to ES5, but I'm not super familiar with what is ES5 and what came after so I could have missed things.

We use a package called localflare to run Cloudflare Workers for testing which depends on this package. I discovered the different behavior between atob and buffer when looking at b64url in our code.

For us making the change is beneficial because the closer we can get our environment to Cloudflare the better (and I'm really against Node's behavior on this) but I also understand being cautious about versioning. I'll just have to make a PR to localflare to update their version :)

(Wrangler is on our roadmap but it will be a little while before we get there)

I changed it to a range check (good advice). I think I've changed it to ES5, but I'm not super familiar with what is ES5 and what came after so I could have missed things. We use a package called localflare to run Cloudflare Workers for testing which depends on this package. I discovered the different behavior between `atob` and `buffer` when looking at b64url in our code. For us making the change is beneficial because the closer we can get our environment to Cloudflare the better (and I'm really against Node's behavior on this) but I also understand being cautious about versioning. I'll just have to make a PR to localflare to update their version :) (Wrangler is on our roadmap but it will be a little while before we get there)
coolaj86 прокомментировал(а) 2021-03-11 19:13:46 +00:00
Владелец

Thanks.
I've scheduled review, update, merge, and publish this on Saturday.

Thanks. I've scheduled review, update, merge, and publish this on Saturday.
Содержимое этого запроса было нарушено вследствие удаления информации форка.
Войдите, чтобы присоединиться к обсуждению.
Нет рецензентов
Нет меток
Нет этапа
Нет назначенных лиц
2 участников
Уведомления
Срок выполнения
Срок действия недействителен или находится за пределами допустимого диапазона. Пожалуйста, используйте формат 'гггг-мм-дд'.

Срок выполнения не установлен.

Зависимости

Зависимостей нет.

Ссылка: coolaj86/atob.js#7
Описание отсутствует.