#!/bin/sh

DOMAIN="${DOMAIN:-lmscabinet.dot-dot.ru}"
# API_URL='"API_URL": "https://dot-dot.ru/"'
# d='https://dot-dot.ru/'

for x in $(grep -lrw "lmscabinet.dot-dot.ru" .nuxt/);do
    echo "replace lmscabinet.dot-dot.ru to https://${DOMAIN} in $x"
    sed -i "s|lmscabinet.dot-dot.ru|${DOMAIN}|g" $x;
done

for x in $(grep -lrw "https://dot-dot.ru" .nuxt/);do
    echo "replace https://dot-dot.ru to ${API_URL} in $x"
    sed -i "s|https://dot-dot.ru|${API_URL}|g" $x;
    # echo "fix double //";
    # sed -i "s|\/\/\|/|g" $x;
done

"$@"
