UNPKG

@wordpress/url

Version:
8 lines (7 loc) 1.17 kB
{ "version": 3, "sources": ["../src/get-path-and-query-string.ts"], "sourcesContent": ["/**\n * Internal dependencies\n */\nimport { getPath, getQueryString } from '.';\n\n/**\n * Returns the path part and query string part of the URL.\n *\n * @param url The full URL.\n *\n * @example\n * ```js\n * const pathAndQueryString1 = getPathAndQueryString( 'http://localhost:8080/this/is/a/test?query=true' ); // '/this/is/a/test?query=true'\n * const pathAndQueryString2 = getPathAndQueryString( 'https://wordpress.org/help/faq/' ); // '/help/faq'\n * ```\n *\n * @return The path part and query string part of the URL.\n */\nexport function getPathAndQueryString( url: string ): string {\n\tconst path = getPath( url );\n\tconst queryString = getQueryString( url );\n\tlet value = '/';\n\tif ( path ) {\n\t\tvalue += path;\n\t}\n\tif ( queryString ) {\n\t\tvalue += `?${ queryString }`;\n\t}\n\treturn value;\n}\n"], "mappings": ";AAGA,SAAS,SAAS,sBAAsB;AAejC,SAAS,sBAAuB,KAAsB;AAC5D,QAAM,OAAO,QAAS,GAAI;AAC1B,QAAM,cAAc,eAAgB,GAAI;AACxC,MAAI,QAAQ;AACZ,MAAK,MAAO;AACX,aAAS;AAAA,EACV;AACA,MAAK,aAAc;AAClB,aAAS,IAAK,WAAY;AAAA,EAC3B;AACA,SAAO;AACR;", "names": [] }