Created
March 24, 2017 14:51
-
-
Save TheSirop/5c30f0f66d1a920e7c3a07a7e2dca65b to your computer and use it in GitHub Desktop.
Задача #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Имеем URL вида: | |
| // http://127.0.0.1:3000/products/dalnomer_lazernyj_bosch_dle | |
| // Данный урл является ключом в JSON который через POST отправляется в 1С | |
| "cart": { | |
| "totalPrice": 1900, | |
| "totalQty": 1, | |
| "items": { | |
| "dalnomer_lazernyj_bosch_dle": { | |
| "price": 1900, | |
| "qty": 1, | |
| "item": {} | |
| } | |
| } | |
| } | |
| // По стичению обстоятельств 1С не может в названии ключа прочитать символ '-' | |
| // что повлекло за собой изменение правила транслитерации при генерировании slug из названия товара | |
| // За генерацию slug отвечает mongoose-slug-generator. | |
| const slug = require('mongoose-slug-generator'); | |
| const options = { | |
| separator: '_', | |
| lang: 'en', | |
| }; | |
| // В итоге из-за подстраивания кода под систему 1С, мы получили в url вместо: | |
| // http://127.0.0.1:3000/products/dalnomer-lazernyj-bosch-dle | |
| // url с нижним подчеркиванием: | |
| // http://127.0.0.1:3000/products/dalnomer_lazernyj_bosch_dle | |
| // Вопрос? Можно ли только для url подменить '_' на '-' ? | |
| // Возможно это должен быть редирект с правилом которое через regexp ищет один символ и заменяет его на другой |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment