order.js 722 B

1234567891011121314151617181920212223242526272829303132333435
  1. import { type_manager } from "./functions.js";
  2. class order {
  3. #shop;
  4. #link;
  5. constructor(link) {
  6. if (!type_manager.is_string(link)) {
  7. throw "Link to the order must be an string.";
  8. }
  9. this.#link = link.trim();
  10. const link_without_protocol = link.split("//").pop();
  11. const parts = link_without_protocol.split("/");
  12. const name = parts.shift();
  13. const subdomains = name.split(".");
  14. if (subdomains[0].search("www") !== -1) {
  15. subdomains.shift();
  16. }
  17. this.#shop = subdomains.join(".");
  18. }
  19. get shop() {
  20. return this.#shop;
  21. }
  22. get link() {
  23. return this.#link;
  24. }
  25. }
  26. export { order };