MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / fx_parseQuery

Function fx_parseQuery

modules/data/url/url.c:1712–1784  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1710}
1711
1712void fx_parseQuery(txMachine* the)
1713{
1714 txSlot* result;
1715 txSlot* string;
1716 txSlot* pair;
1717 txSlot* push;
1718 txInteger offset, ampersand, equal;
1719 fxVars(the, 2);
1720 result = mxResult;
1721 string = mxArgv(0);
1722 pair = mxVarv(0);
1723 push = mxVarv(1);
1724
1725 fxNewArray(the, 0);
1726 mxPullSlot(result);
1727
1728 fxToString(the, string);
1729
1730 mxPushSlot(result);
1731 mxGetID(mxID(_push));
1732 mxPullSlot(push);
1733
1734 offset = 0;
1735 ampersand = 0;
1736 equal = 0;
1737 if (string->value.string[0] == '?') {
1738 offset++;
1739 ampersand++;
1740 equal++;
1741 }
1742 for (;;) {
1743 char c = string->value.string[offset];
1744 if ((c == 0) || (c == '&')) {
1745 if (offset > ampersand) {
1746 mxPushSlot(result);
1747 mxPushSlot(push);
1748 mxCall();
1749
1750 fxNewInstance(the);
1751 mxPullSlot(pair);
1752
1753 if (equal == ampersand)
1754 equal = offset;
1755 fx_parseQueryPlus(the, string, ampersand, equal);
1756 mxPushSlot(pair);
1757 mxSetID(mxID(_name));
1758 mxPop();
1759
1760 equal++;
1761
1762 if (equal < offset)
1763 fx_parseQueryPlus(the, string, equal, offset);
1764 else
1765 mxPush(mxEmptyString);
1766 mxPushSlot(pair);
1767 mxSetID(mxID(_value));
1768 mxPop();
1769

Callers

nothing calls this directly

Calls 5

fxVarsFunction · 0.85
fxNewArrayFunction · 0.85
fxToStringFunction · 0.85
fxNewInstanceFunction · 0.85
fx_parseQueryPlusFunction · 0.85

Tested by

no test coverage detected