MCPcopy Create free account
hub / github.com/ChromeDevTools/devtools-frontend / trimSourceURLComment

Method trimSourceURLComment

front_end/core/sdk/Script.ts:135–152  ·  view source on GitHub ↗
(source: string)

Source from the content-addressed store, hash-verified

133 }
134
135 private static trimSourceURLComment(source: string): string {
136 let sourceURLIndex = source.lastIndexOf('//# sourceURL=');
137 if (sourceURLIndex === -1) {
138 sourceURLIndex = source.lastIndexOf('//@ sourceURL=');
139 if (sourceURLIndex === -1) {
140 return source;
141 }
142 }
143 const sourceURLLineIndex = source.lastIndexOf('\n', sourceURLIndex);
144 if (sourceURLLineIndex === -1) {
145 return source;
146 }
147 const sourceURLLine = source.substr(sourceURLLineIndex + 1);
148 if (!sourceURLLine.match(sourceURLRegex)) {
149 return source;
150 }
151 return source.substr(0, sourceURLLineIndex);
152 }
153
154 isContentScript(): boolean {
155 return this.#isContentScript;

Callers 2

loadTextContentMethod · 0.80
editSourceMethod · 0.80

Calls 2

substrMethod · 0.80
matchMethod · 0.45

Tested by

no test coverage detected